html-webpack-plugin 3.2.0 → 4.0.0-alpha
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 +14 -18
- package/default_index.ejs +1 -1
- package/index.js +298 -336
- package/lib/chunksorter.js +26 -118
- package/lib/compiler.js +5 -16
- package/lib/errors.js +2 -1
- package/lib/hooks.js +132 -0
- package/lib/html-tags.js +73 -0
- package/lib/loader.js +4 -4
- package/package.json +11 -8
package/README.md
CHANGED
|
@@ -86,7 +86,7 @@ This will generate a file `dist/index.html` containing the following
|
|
|
86
86
|
<!DOCTYPE html>
|
|
87
87
|
<html>
|
|
88
88
|
<head>
|
|
89
|
-
<meta charset="
|
|
89
|
+
<meta charset="utf-8">
|
|
90
90
|
<title>Webpack App</title>
|
|
91
91
|
</head>
|
|
92
92
|
<body>
|
|
@@ -109,14 +109,14 @@ Allowed values are as follows
|
|
|
109
109
|
|
|
110
110
|
|Name|Type|Default|Description|
|
|
111
111
|
|:--:|:--:|:-----:|:----------|
|
|
112
|
-
|**[`title`](#)**|`{String}
|
|
112
|
+
|**[`title`](#)**|`{String}`|`Webpack App`|The title to use for the generated HTML document|
|
|
113
113
|
|**[`filename`](#)**|`{String}`|`'index.html'`|The file to write the HTML to. Defaults to `index.html`. You can specify a subdirectory here too (eg: `assets/admin.html`)|
|
|
114
114
|
|**[`template`](#)**|`{String}`|``|`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|
|
|
115
115
|
|**[`templateParameters`](#)**|`{Boolean\|Object\|Function}`|``| Allows to overwrite the parameters used in the template |
|
|
116
116
|
|**[`inject`](#)**|`{Boolean\|String}`|`true`|`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|
|
|
117
117
|
|**[`favicon`](#)**|`{String}`|``|Adds the given favicon path to the output HTML|
|
|
118
118
|
|**[`meta`](#)**|`{Object}`|`{}`|Allows to inject `meta`-tags. E.g. `meta: {viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'}`|
|
|
119
|
-
|**[`minify`](#)**|`{Boolean\|Object}`|`
|
|
119
|
+
|**[`minify`](#)**|`{Boolean\|Object}`|`false`|Pass [html-minifier](https://github.com/kangax/html-minifier#options-quick-reference)'s options as object to minify the output|
|
|
120
120
|
|**[`hash`](#)**|`{Boolean}`|`false`|If `true` then append a unique `webpack` compilation hash to all included scripts and CSS files. This is useful for cache busting|
|
|
121
121
|
|**[`cache`](#)**|`{Boolean}`|`true`|Emit the file only if it was changed|
|
|
122
122
|
|**[`showErrors`](#)**|`{Boolean}`|`true`|Errors details will be written into the HTML page|
|
|
@@ -189,7 +189,7 @@ plugins: [
|
|
|
189
189
|
<!DOCTYPE html>
|
|
190
190
|
<html>
|
|
191
191
|
<head>
|
|
192
|
-
<meta
|
|
192
|
+
<meta charset="utf-8"/>
|
|
193
193
|
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
194
194
|
</head>
|
|
195
195
|
<body>
|
|
@@ -204,7 +204,7 @@ Please note that this will also happen if you specifiy the html-loader and use `
|
|
|
204
204
|
```js
|
|
205
205
|
module: {
|
|
206
206
|
loaders: [
|
|
207
|
-
{ test: /\.hbs$/, loader: "handlebars" }
|
|
207
|
+
{ test: /\.hbs$/, loader: "handlebars-loader" }
|
|
208
208
|
]
|
|
209
209
|
},
|
|
210
210
|
plugins: [
|
|
@@ -289,17 +289,13 @@ plugins: [
|
|
|
289
289
|
|
|
290
290
|
To allow other [plugins](https://github.com/webpack/docs/wiki/plugins) to alter the HTML this plugin executes the following events:
|
|
291
291
|
|
|
292
|
-
#### `
|
|
292
|
+
#### `AsyncSeriesWaterfallHook`
|
|
293
293
|
|
|
294
|
-
* `
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
* `
|
|
299
|
-
* `html-webpack-plugin-before-html-processing`
|
|
300
|
-
* `html-webpack-plugin-alter-asset-tags`
|
|
301
|
-
* `html-webpack-plugin-after-html-processing`
|
|
302
|
-
* `html-webpack-plugin-after-emit`
|
|
294
|
+
* `htmlWebpackPluginBeforeHtmlGeneration`
|
|
295
|
+
* `htmlWebpackPluginBeforeHtmlProcessing`
|
|
296
|
+
* `htmlWebpackPluginAlterAssetTags`
|
|
297
|
+
* `htmlWebpackPluginAfterHtmlProcessing`
|
|
298
|
+
* `htmlWebpackPluginAfterEmit`
|
|
303
299
|
|
|
304
300
|
Example implementation: [html-webpack-harddisk-plugin](https://github.com/jantimon/html-webpack-harddisk-plugin)
|
|
305
301
|
|
|
@@ -310,11 +306,11 @@ function MyPlugin(options) {
|
|
|
310
306
|
}
|
|
311
307
|
|
|
312
308
|
MyPlugin.prototype.apply = function (compiler) {
|
|
313
|
-
compiler.
|
|
309
|
+
compiler.hooks.compilation.tap('MyPlugin', (compilation) => {
|
|
314
310
|
console.log('The compiler is starting a new compilation...');
|
|
315
311
|
|
|
316
|
-
compilation.
|
|
317
|
-
'
|
|
312
|
+
compilation.hooks.htmlWebpackPluginAfterHtmlProcessing.tapAsync(
|
|
313
|
+
'MyPlugin',
|
|
318
314
|
(data, cb) => {
|
|
319
315
|
data.html += 'The Magic Footer'
|
|
320
316
|
|