html-webpack-plugin 3.0.7 → 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/CHANGELOG.md +37 -0
- package/README.md +65 -34
- package/default_index.ejs +1 -1
- package/index.js +351 -347
- package/lib/chunksorter.js +26 -116
- package/lib/compiler.js +13 -17
- package/lib/errors.js +2 -1
- package/lib/hooks.js +132 -0
- package/lib/html-tags.js +73 -0
- package/lib/loader.js +8 -24
- package/package.json +20 -9
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
<a name="3.2.0"></a>
|
|
6
|
+
# [3.2.0](https://github.com/jantimon/html-webpack-plugin/compare/v3.1.0...v3.2.0) (2018-04-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **loader:** Allow to add new template parameters ([f7eac19](https://github.com/jantimon/html-webpack-plugin/commit/f7eac19)), closes [#915](https://github.com/jantimon/html-webpack-plugin/issues/915)
|
|
12
|
+
* **loader:** Use lodash inside the loader directly ([7b4eb7f](https://github.com/jantimon/html-webpack-plugin/commit/7b4eb7f)), closes [#786](https://github.com/jantimon/html-webpack-plugin/issues/786)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* Add meta tag option ([a7d37ca](https://github.com/jantimon/html-webpack-plugin/commit/a7d37ca))
|
|
18
|
+
* Support node 6.9 ([74a22c4](https://github.com/jantimon/html-webpack-plugin/commit/74a22c4)), closes [#918](https://github.com/jantimon/html-webpack-plugin/issues/918)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
<a name="3.1.0"></a>
|
|
23
|
+
# [3.1.0](https://github.com/jantimon/html-webpack-plugin/compare/v3.0.8...v3.1.0) (2018-03-22)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
* Allow to overwrite the templateParameter [#830](https://github.com/jantimon/html-webpack-plugin/issues/830) ([c5e32d3](https://github.com/jantimon/html-webpack-plugin/commit/c5e32d3))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
<a name="3.0.8"></a>
|
|
33
|
+
## [3.0.8](https://github.com/jantimon/html-webpack-plugin/compare/v3.0.7...v3.0.8) (2018-03-22)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* **compiler:** Fallback to 3.0.7 because of [#900](https://github.com/jantimon/html-webpack-plugin/issues/900) ([05ee29b](https://github.com/jantimon/html-webpack-plugin/commit/05ee29b))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
5
42
|
<a name="3.0.7"></a>
|
|
6
43
|
## [3.0.7](https://github.com/jantimon/html-webpack-plugin/compare/v3.0.6...v3.0.7) (2018-03-19)
|
|
7
44
|
|
package/README.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
[![npm][npm]][npm-url]
|
|
2
2
|
[![node][node]][node-url]
|
|
3
|
+

|
|
3
4
|
[![deps][deps]][deps-url]
|
|
4
5
|
[![tests][tests]][tests-url]
|
|
5
|
-
[](#backers)
|
|
7
|
+
[](#sponsors)
|
|
7
8
|
|
|
8
9
|
<div align="center">
|
|
9
10
|
<img width="200" height="200" src="https://worldvectorlogo.com/logos/html5.svg">
|
|
@@ -53,6 +54,9 @@ The `html-webpack-plugin` provides [hooks](https://github.com/jantimon/html-webp
|
|
|
53
54
|
* [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
|
|
54
55
|
* [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>`
|
|
55
56
|
* [html-webpack-inline-style-plugin](https://github.com/djaax/html-webpack-inline-style-plugin) for inlining styles to HTML elements using [juice](https://github.com/Automattic/juice). Useful for email generation automatisation.
|
|
57
|
+
* [html-webpack-exclude-empty-assets-plugin](https://github.com/KnisterPeter/html-webpack-exclude-empty-assets-plugin) removes empty assets from being added to the html. This fixes some problems with extract-text-plugin with webpack 4.
|
|
58
|
+
* [webpack-concat-plugin](https://github.com/hxlniada/webpack-concat-plugin) for concat and uglify files that needn't to be webpack bundles(for legacy files) and inject to html-webpack-plugin.
|
|
59
|
+
|
|
56
60
|
|
|
57
61
|
<h2 align="center">Usage</h2>
|
|
58
62
|
|
|
@@ -82,7 +86,7 @@ This will generate a file `dist/index.html` containing the following
|
|
|
82
86
|
<!DOCTYPE html>
|
|
83
87
|
<html>
|
|
84
88
|
<head>
|
|
85
|
-
<meta charset="
|
|
89
|
+
<meta charset="utf-8">
|
|
86
90
|
<title>Webpack App</title>
|
|
87
91
|
</head>
|
|
88
92
|
<body>
|
|
@@ -105,18 +109,20 @@ Allowed values are as follows
|
|
|
105
109
|
|
|
106
110
|
|Name|Type|Default|Description|
|
|
107
111
|
|:--:|:--:|:-----:|:----------|
|
|
108
|
-
|**[`title`](#)**|`{String}
|
|
112
|
+
|**[`title`](#)**|`{String}`|`Webpack App`|The title to use for the generated HTML document|
|
|
109
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`)|
|
|
110
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
|
+
|**[`templateParameters`](#)**|`{Boolean\|Object\|Function}`|``| Allows to overwrite the parameters used in the template |
|
|
111
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|
|
|
112
117
|
|**[`favicon`](#)**|`{String}`|``|Adds the given favicon path to the output HTML|
|
|
113
|
-
|**[`
|
|
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}`|`false`|Pass [html-minifier](https://github.com/kangax/html-minifier#options-quick-reference)'s options as object to minify the output|
|
|
114
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|
|
|
115
121
|
|**[`cache`](#)**|`{Boolean}`|`true`|Emit the file only if it was changed|
|
|
116
122
|
|**[`showErrors`](#)**|`{Boolean}`|`true`|Errors details will be written into the HTML page|
|
|
117
123
|
|**[`chunks`](#)**|`{?}`|`?`|Allows you to add only some chunks (e.g only the unit-test chunk)|
|
|
118
124
|
|**[`chunksSortMode`](#plugins)**|`{String\|Function}`|`auto`|Allows to control how chunks should be sorted before they are included to the HTML. Allowed values are `'none' \| 'auto' \| 'dependency' \| 'manual' \| {Function}`|
|
|
119
|
-
|**[`excludeChunks`](#)**|`{
|
|
125
|
+
|**[`excludeChunks`](#)**|`{Array.<string>}`|``|Allows you to skip some chunks (e.g don't add the unit-test chunk)|
|
|
120
126
|
|**[`xhtml`](#)**|`{Boolean}`|`false`|If `true` render the `link` tags as self-closing (XHTML compliant)|
|
|
121
127
|
|
|
122
128
|
Here's an example webpack config illustrating how to use these options
|
|
@@ -183,7 +189,7 @@ plugins: [
|
|
|
183
189
|
<!DOCTYPE html>
|
|
184
190
|
<html>
|
|
185
191
|
<head>
|
|
186
|
-
<meta
|
|
192
|
+
<meta charset="utf-8"/>
|
|
187
193
|
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
188
194
|
</head>
|
|
189
195
|
<body>
|
|
@@ -198,7 +204,7 @@ Please note that this will also happen if you specifiy the html-loader and use `
|
|
|
198
204
|
```js
|
|
199
205
|
module: {
|
|
200
206
|
loaders: [
|
|
201
|
-
{ test: /\.hbs$/, loader: "handlebars" }
|
|
207
|
+
{ test: /\.hbs$/, loader: "handlebars-loader" }
|
|
202
208
|
]
|
|
203
209
|
},
|
|
204
210
|
plugins: [
|
|
@@ -283,17 +289,13 @@ plugins: [
|
|
|
283
289
|
|
|
284
290
|
To allow other [plugins](https://github.com/webpack/docs/wiki/plugins) to alter the HTML this plugin executes the following events:
|
|
285
291
|
|
|
286
|
-
#### `
|
|
292
|
+
#### `AsyncSeriesWaterfallHook`
|
|
287
293
|
|
|
288
|
-
* `
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
* `
|
|
293
|
-
* `html-webpack-plugin-before-html-processing`
|
|
294
|
-
* `html-webpack-plugin-alter-asset-tags`
|
|
295
|
-
* `html-webpack-plugin-after-html-processing`
|
|
296
|
-
* `html-webpack-plugin-after-emit`
|
|
294
|
+
* `htmlWebpackPluginBeforeHtmlGeneration`
|
|
295
|
+
* `htmlWebpackPluginBeforeHtmlProcessing`
|
|
296
|
+
* `htmlWebpackPluginAlterAssetTags`
|
|
297
|
+
* `htmlWebpackPluginAfterHtmlProcessing`
|
|
298
|
+
* `htmlWebpackPluginAfterEmit`
|
|
297
299
|
|
|
298
300
|
Example implementation: [html-webpack-harddisk-plugin](https://github.com/jantimon/html-webpack-harddisk-plugin)
|
|
299
301
|
|
|
@@ -304,11 +306,11 @@ function MyPlugin(options) {
|
|
|
304
306
|
}
|
|
305
307
|
|
|
306
308
|
MyPlugin.prototype.apply = function (compiler) {
|
|
307
|
-
compiler.
|
|
309
|
+
compiler.hooks.compilation.tap('MyPlugin', (compilation) => {
|
|
308
310
|
console.log('The compiler is starting a new compilation...');
|
|
309
311
|
|
|
310
|
-
compilation.
|
|
311
|
-
'
|
|
312
|
+
compilation.hooks.htmlWebpackPluginAfterHtmlProcessing.tapAsync(
|
|
313
|
+
'MyPlugin',
|
|
312
314
|
(data, cb) => {
|
|
313
315
|
data.html += 'The Magic Footer'
|
|
314
316
|
|
|
@@ -330,15 +332,6 @@ plugins: [
|
|
|
330
332
|
|
|
331
333
|
Note that the callback must be passed the HtmlWebpackPluginData in order to pass this onto any other plugins listening on the same `html-webpack-plugin-before-html-processing` event
|
|
332
334
|
|
|
333
|
-
<h2 align="center">Contribution</h2>
|
|
334
|
-
|
|
335
|
-
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.
|
|
336
|
-
|
|
337
|
-
This project uses the [semistandard code style](https://github.com/Flet/semistandard).
|
|
338
|
-
|
|
339
|
-
Before running the tests, make sure to execute `yarn link` and `yarn link html-webpack-plugin` (or the `npm` variant of this).
|
|
340
|
-
|
|
341
|
-
|
|
342
335
|
<h2 align="center">Maintainers</h2>
|
|
343
336
|
|
|
344
337
|
<table>
|
|
@@ -373,8 +366,46 @@ Before running the tests, make sure to execute `yarn link` and `yarn link html-w
|
|
|
373
366
|
[tests]: http://img.shields.io/travis/jantimon/html-webpack-plugin.svg
|
|
374
367
|
[tests-url]: https://travis-ci.org/jantimon/html-webpack-plugin
|
|
375
368
|
|
|
376
|
-
[cover]: https://img.shields.io/codecov/c/github/jantimon/html-webpack-plugin.svg
|
|
377
|
-
[cover-url]: https://codecov.io/gh/jantimon/html-webpack-plugin
|
|
378
369
|
|
|
379
|
-
|
|
380
|
-
|
|
370
|
+
## Contributors
|
|
371
|
+
|
|
372
|
+
This project exists thanks to all the people who contribute.
|
|
373
|
+
|
|
374
|
+
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.
|
|
375
|
+
|
|
376
|
+
This project uses the [semistandard code style](https://github.com/Flet/semistandard).
|
|
377
|
+
|
|
378
|
+
<a href="https://github.com/jantimon/html-webpack-plugin/graphs/contributors"><img src="https://opencollective.com/html-webpack-plugin/contributors.svg?width=890&button=false" /></a>
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
## Backers
|
|
382
|
+
|
|
383
|
+
Thank you to all our backers! 🙏 [Become a backer](https://opencollective.com/html-webpack-plugin#backer)
|
|
384
|
+
|
|
385
|
+
<a href="https://opencollective.com/html-webpack-plugin/backer/0/website?requireActive=false" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/backer/0/avatar.svg?requireActive=false"></a>
|
|
386
|
+
<a href="https://opencollective.com/html-webpack-plugin/backer/1/website?requireActive=false" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/backer/1/avatar.svg?requireActive=false"></a>
|
|
387
|
+
<a href="https://opencollective.com/html-webpack-plugin/backer/2/website?requireActive=false" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/backer/2/avatar.svg?requireActive=false"></a>
|
|
388
|
+
<a href="https://opencollective.com/html-webpack-plugin/backer/3/website?requireActive=false" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/backer/3/avatar.svg?requireActive=false"></a>
|
|
389
|
+
<a href="https://opencollective.com/html-webpack-plugin/backer/4/website?requireActive=false" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/backer/4/avatar.svg?requireActive=false"></a>
|
|
390
|
+
<a href="https://opencollective.com/html-webpack-plugin/backer/5/website?requireActive=false" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/backer/5/avatar.svg?requireActive=false"></a>
|
|
391
|
+
<a href="https://opencollective.com/html-webpack-plugin/backer/6/website?requireActive=false" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/backer/6/avatar.svg?requireActive=false"></a>
|
|
392
|
+
<a href="https://opencollective.com/html-webpack-plugin/backer/7/website?requireActive=false" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/backer/7/avatar.svg?requireActive=false"></a>
|
|
393
|
+
<a href="https://opencollective.com/html-webpack-plugin/backer/8/website?requireActive=false" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/backer/8/avatar.svg?requireActive=false"></a>
|
|
394
|
+
<a href="https://opencollective.com/html-webpack-plugin/backer/9/website?requireActive=false" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/backer/9/avatar.svg?requireActive=false"></a>
|
|
395
|
+
|
|
396
|
+
## Sponsors
|
|
397
|
+
|
|
398
|
+
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor](https://opencollective.com/html-webpack-plugin#sponsor)
|
|
399
|
+
|
|
400
|
+
<a href="https://opencollective.com/html-webpack-plugin/sponsor/0/website" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/sponsor/0/avatar.svg"></a>
|
|
401
|
+
<a href="https://opencollective.com/html-webpack-plugin/sponsor/1/website" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/sponsor/1/avatar.svg"></a>
|
|
402
|
+
<a href="https://opencollective.com/html-webpack-plugin/sponsor/2/website" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/sponsor/2/avatar.svg"></a>
|
|
403
|
+
<a href="https://opencollective.com/html-webpack-plugin/sponsor/3/website" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/sponsor/3/avatar.svg"></a>
|
|
404
|
+
<a href="https://opencollective.com/html-webpack-plugin/sponsor/4/website" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/sponsor/4/avatar.svg"></a>
|
|
405
|
+
<a href="https://opencollective.com/html-webpack-plugin/sponsor/5/website" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/sponsor/5/avatar.svg"></a>
|
|
406
|
+
<a href="https://opencollective.com/html-webpack-plugin/sponsor/6/website" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/sponsor/6/avatar.svg"></a>
|
|
407
|
+
<a href="https://opencollective.com/html-webpack-plugin/sponsor/7/website" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/sponsor/7/avatar.svg"></a>
|
|
408
|
+
<a href="https://opencollective.com/html-webpack-plugin/sponsor/8/website" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/sponsor/8/avatar.svg"></a>
|
|
409
|
+
<a href="https://opencollective.com/html-webpack-plugin/sponsor/9/website" target="_blank"><img src="https://opencollective.com/html-webpack-plugin/sponsor/9/avatar.svg"></a>
|
|
410
|
+
|
|
411
|
+
|