html-webpack-plugin 2.28.0 → 2.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -17
- package/index.js +0 -1
- package/lib/chunksorter.js +1 -1
- package/lib/loader.js +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
HTML Webpack Plugin
|
|
2
2
|
===================
|
|
3
|
-
[](http://badge.fury.io/js/html-webpack-plugin) [](http://badge.fury.io/js/html-webpack-plugin) [](https://david-dm.org/jantimon/html-webpack-plugin) [](https://travis-ci.org/jantimon/html-webpack-plugin) [](https://ci.appveyor.com/project/jantimon/html-webpack-plugin) [](https://github.com/Flet/semistandard) [](https://www.bithound.io/github/jantimon/html-webpack-plugin/master/dependencies/npm) []()
|
|
4
4
|
|
|
5
5
|
[](https://nodei.co/npm/html-webpack-plugin/)
|
|
6
6
|
|
|
@@ -21,20 +21,23 @@ $ npm install html-webpack-plugin --save-dev
|
|
|
21
21
|
Third party addons:
|
|
22
22
|
-------------
|
|
23
23
|
|
|
24
|
-
The html-webpack-plugin provides [hooks](https://github.com/
|
|
24
|
+
The html-webpack-plugin provides [hooks](https://github.com/jantimon/html-webpack-plugin#events) to extend it to your needs.
|
|
25
25
|
There are already some really powerful plugins which can be integrated with zero configuration:
|
|
26
26
|
|
|
27
27
|
* [webpack-subresource-integrity](https://www.npmjs.com/package/webpack-subresource-integrity) for enhanced asset security
|
|
28
28
|
* [appcache-webpack-plugin](https://github.com/lettertwo/appcache-webpack-plugin) for iOS and Android offline usage
|
|
29
29
|
* [favicons-webpack-plugin](https://github.com/jantimon/favicons-webpack-plugin) which generates favicons and icons for iOS, Android and desktop browsers
|
|
30
|
-
* [html-webpack-harddisk-plugin](https://github.com/jantimon/html-webpack-harddisk-plugin)
|
|
30
|
+
* [html-webpack-harddisk-plugin](https://github.com/jantimon/html-webpack-harddisk-plugin) can be used to always write to disk the html file, useful when webpack-dev-server / HMR are being used
|
|
31
31
|
* [html-webpack-inline-source-plugin](https://github.com/DustinJackson/html-webpack-inline-source-plugin) to inline your assets in the resulting HTML file
|
|
32
|
-
* [html-webpack-exclude-assets-plugin](https://github.com/jamesjieye/html-webpack-exclude-assets-plugin) for excluding assets using regular expressions
|
|
32
|
+
* [html-webpack-exclude-assets-plugin](https://github.com/jamesjieye/html-webpack-exclude-assets-plugin) for excluding assets using regular expressions
|
|
33
33
|
* [html-webpack-include-assets-plugin](https://github.com/jharris4/html-webpack-include-assets-plugin) for including lists of js or css file paths (such as those copied by the copy-webpack-plugin).
|
|
34
34
|
* [script-ext-html-webpack-plugin](https://github.com/numical/script-ext-html-webpack-plugin) to add `async`, `defer` or `module` attributes to your`<script>` elements, or even in-line them
|
|
35
35
|
* [style-ext-html-webpack-plugin](https://github.com/numical/style-ext-html-webpack-plugin) to convert your `<link>`s to external stylesheets into `<style>` elements containing internal CSS
|
|
36
|
-
* [resource-hints-webpack-plugin](https://github.com/jantimon/resource-hints-webpack-plugin) to add resource hints for faster initial page loads
|
|
37
|
-
|
|
36
|
+
* [resource-hints-webpack-plugin](https://github.com/jantimon/resource-hints-webpack-plugin) to add resource hints for faster initial page loads using `<link rel='preload'>` and `<link rel='prefetch'>`
|
|
37
|
+
* [preload-webpack-plugin](https://github.com/GoogleChrome/preload-webpack-plugin) for automatically wiring up asynchronous (and other types) of JavaScript chunks using `<link rel='preload'>` helping with lazy-loading
|
|
38
|
+
* [link-media-html-webpack-plugin](https://github.com/yaycmyk/link-media-html-webpack-plugin) allows for injected stylesheet `<link />` tags to have their media attribute set automatically; useful for providing specific desktop/mobile/print etc. stylesheets that the browser will conditionally download
|
|
39
|
+
* [inline-chunk-manifest-html-webpack-plugin](https://github.com/jouni-kantola/inline-chunk-manifest-html-webpack-plugin) for inlining webpack's chunk manifest. Default extracts manifest and inlines in `<head>`.
|
|
40
|
+
|
|
38
41
|
Basic Usage
|
|
39
42
|
-----------
|
|
40
43
|
|
|
@@ -47,7 +50,7 @@ var HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
47
50
|
var webpackConfig = {
|
|
48
51
|
entry: 'index.js',
|
|
49
52
|
output: {
|
|
50
|
-
path: 'dist',
|
|
53
|
+
path: __dirname + '/dist',
|
|
51
54
|
filename: 'index_bundle.js'
|
|
52
55
|
},
|
|
53
56
|
plugins: [new HtmlWebpackPlugin()]
|
|
@@ -83,10 +86,10 @@ Allowed values are as follows:
|
|
|
83
86
|
- `title`: The title to use for the generated HTML document.
|
|
84
87
|
- `filename`: The file to write the HTML to. Defaults to `index.html`.
|
|
85
88
|
You can specify a subdirectory here too (eg: `assets/admin.html`).
|
|
86
|
-
- `template`: Webpack require path to the template. Please see the [docs](https://github.com/
|
|
89
|
+
- `template`: Webpack require path to the template. Please see the [docs](https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md) for details.
|
|
87
90
|
- `inject`: `true | 'head' | 'body' | false` Inject all assets into the given `template` or `templateContent` - When passing `true` or `'body'` all javascript resources will be placed at the bottom of the body element. `'head'` will place the scripts in the head element.
|
|
88
91
|
- `favicon`: Adds the given favicon path to the output html.
|
|
89
|
-
- `minify`: `{...} | false` Pass
|
|
92
|
+
- `minify`: `{...} | false` Pass [html-minifier](https://github.com/kangax/html-minifier#options-quick-reference)'s options as object to minify the output.
|
|
90
93
|
- `hash`: `true | false` if `true` then append a unique webpack compilation hash to all
|
|
91
94
|
included scripts and CSS files. This is useful for cache busting.
|
|
92
95
|
- `cache`: `true | false` if `true` (default) try to emit the file only if it was changed.
|
|
@@ -101,7 +104,7 @@ Here's an example webpack config illustrating how to use these options:
|
|
|
101
104
|
{
|
|
102
105
|
entry: 'index.js',
|
|
103
106
|
output: {
|
|
104
|
-
path: 'dist',
|
|
107
|
+
path: __dirname + '/dist',
|
|
105
108
|
filename: 'index_bundle.js'
|
|
106
109
|
},
|
|
107
110
|
plugins: [
|
|
@@ -116,9 +119,9 @@ Here's an example webpack config illustrating how to use these options:
|
|
|
116
119
|
FAQ
|
|
117
120
|
----
|
|
118
121
|
|
|
119
|
-
* [Why is my HTML minified?](https://github.com/
|
|
120
|
-
* [Why is my `<% ... %>` template not working?](https://github.com/
|
|
121
|
-
* [How can I use handlebars/pug/ejs as template engine](https://github.com/
|
|
122
|
+
* [Why is my HTML minified?](https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md)
|
|
123
|
+
* [Why is my `<% ... %>` template not working?](https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md)
|
|
124
|
+
* [How can I use handlebars/pug/ejs as template engine](https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md)
|
|
122
125
|
|
|
123
126
|
Generating Multiple HTML Files
|
|
124
127
|
------------------------------
|
|
@@ -128,7 +131,7 @@ once in your plugins array:
|
|
|
128
131
|
{
|
|
129
132
|
entry: 'index.js',
|
|
130
133
|
output: {
|
|
131
|
-
path: 'dist',
|
|
134
|
+
path: __dirname + '/dist',
|
|
132
135
|
filename: 'index_bundle.js'
|
|
133
136
|
},
|
|
134
137
|
plugins: [
|
|
@@ -224,7 +227,7 @@ The following variables are available in the template:
|
|
|
224
227
|
- `webpack`: the webpack [stats](https://github.com/webpack/docs/wiki/node.js-api#stats)
|
|
225
228
|
object. Note that this is the stats object as it was at the time the HTML template
|
|
226
229
|
was emitted and as such may not have the full set of stats that are available
|
|
227
|
-
after the
|
|
230
|
+
after the webpack run is complete.
|
|
228
231
|
|
|
229
232
|
- `webpackConfig`: the webpack configuration that was used for this compilation. This
|
|
230
233
|
can be used, for example, to get the `publicPath` (`webpackConfig.output.publicPath`).
|
|
@@ -309,11 +312,11 @@ Note that the callback must be passed the htmlPluginData in order to pass this o
|
|
|
309
312
|
|
|
310
313
|
# Contribution
|
|
311
314
|
|
|
312
|
-
You're free to contribute to this project by submitting [issues](https://github.com/
|
|
315
|
+
You're free to contribute to this project by submitting [issues](https://github.com/jantimon/html-webpack-plugin/issues) and/or [pull requests](https://github.com/jantimon/html-webpack-plugin/pulls). This project is test-driven, so keep in mind that every change and new feature should be covered by tests.
|
|
313
316
|
This project uses the [semistandard code style](https://github.com/Flet/semistandard).
|
|
314
317
|
|
|
315
318
|
Before running the tests, make sure to execute `yarn link` and `yarn link html-webpack-plugin` (or the npm variant of this).
|
|
316
319
|
|
|
317
320
|
# License
|
|
318
321
|
|
|
319
|
-
This project is licensed under [MIT](https://github.com/
|
|
322
|
+
This project is licensed under [MIT](https://github.com/jantimon/html-webpack-plugin/blob/master/LICENSE).
|
package/index.js
CHANGED
|
@@ -144,7 +144,6 @@ HtmlWebpackPlugin.prototype.apply = function (compiler) {
|
|
|
144
144
|
.then(function (result) {
|
|
145
145
|
var html = result.html;
|
|
146
146
|
var assets = result.assets;
|
|
147
|
-
var chunks = result.chunks;
|
|
148
147
|
// Prepare script and link tags
|
|
149
148
|
var assetTags = self.generateAssetTags(assets);
|
|
150
149
|
var pluginArgs = {head: assetTags.head, body: assetTags.body, plugin: self, chunks: chunks, outputName: self.childCompilationOutputName};
|
package/lib/chunksorter.js
CHANGED
|
@@ -88,6 +88,6 @@ module.exports.auto = module.exports.id;
|
|
|
88
88
|
// In webpack 2 the ids have been flipped.
|
|
89
89
|
// Therefore the id sort doesn't work the same way as it did for webpack 1
|
|
90
90
|
// Luckily the dependency sort is working as expected
|
|
91
|
-
if (require('webpack/package.json').version.split('.')[0]
|
|
91
|
+
if (Number(require('webpack/package.json').version.split('.')[0]) > 1) {
|
|
92
92
|
module.exports.auto = module.exports.dependency;
|
|
93
93
|
}
|
package/lib/loader.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-webpack-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.29.0",
|
|
4
4
|
"description": "Simplifies creation of HTML files to serve your webpack bundles",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
19
|
-
"url": "https://github.com/
|
|
19
|
+
"url": "https://github.com/jantimon/html-webpack-plugin.git"
|
|
20
20
|
},
|
|
21
21
|
"keywords": [
|
|
22
22
|
"webpack",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"author": "Charles Blaxland <charles.blaxland@gmail.com> (https://github.com/ampedandwired)",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"bugs": {
|
|
30
|
-
"url": "https://github.com/
|
|
30
|
+
"url": "https://github.com/jantimon/html-webpack-plugin/issues"
|
|
31
31
|
},
|
|
32
|
-
"homepage": "https://github.com/
|
|
32
|
+
"homepage": "https://github.com/jantimon/html-webpack-plugin",
|
|
33
33
|
"semistandard": {
|
|
34
34
|
"ignore": [
|
|
35
35
|
"examples/*/dist/**/*.*"
|
|
@@ -63,6 +63,6 @@
|
|
|
63
63
|
"toposort": "^1.0.0"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"webpack": "1 || ^2 || ^2.1.0-beta || ^2.2.0-rc"
|
|
66
|
+
"webpack": "1 || ^2 || ^2.1.0-beta || ^2.2.0-rc || ^3"
|
|
67
67
|
}
|
|
68
68
|
}
|