html-webpack-plugin 4.0.0-beta.7 → 4.0.0-beta.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-webpack-plugin",
3
- "version": "4.0.0-beta.7",
3
+ "version": "4.0.0-beta.8",
4
4
  "license": "MIT",
5
5
  "description": "Simplifies creation of HTML files to serve your webpack bundles",
6
6
  "author": "Jan Nicklas <j.nicklas@me.com> (https://github.com/jantimon)",
package/typings.d.ts CHANGED
@@ -1,10 +1,13 @@
1
1
  import { AsyncSeriesWaterfallHook } from "tapable";
2
+ import { Compiler } from 'webpack';
2
3
  import { Options as HtmlMinifierOptions } from "html-minifier";
3
4
 
4
5
  export = HtmlWebpackPlugin;
5
6
 
6
7
  declare class HtmlWebpackPlugin {
7
8
  constructor(options?: HtmlWebpackPlugin.Options);
9
+
10
+ apply(compiler: Compiler): void;
8
11
  }
9
12
 
10
13
  declare namespace HtmlWebpackPlugin {
@@ -102,22 +105,19 @@ declare namespace HtmlWebpackPlugin {
102
105
  | false // Pass an empty object to the template function
103
106
  | ((
104
107
  compilation: any,
105
- assets,
106
- assetTags: {
107
- headTags: HtmlTagObject[];
108
- bodyTags: HtmlTagObject[];
108
+ assets: {
109
+ publicPath: string;
110
+ js: Array<string>;
111
+ css: Array<string>;
112
+ manifest?: string;
113
+ favicon?: string;
109
114
  },
110
- options: ProcessedOptions
111
- ) => { [option: string]: any })
112
- | ((
113
- compilation: any,
114
- assets,
115
115
  assetTags: {
116
116
  headTags: HtmlTagObject[];
117
117
  bodyTags: HtmlTagObject[];
118
118
  },
119
119
  options: ProcessedOptions
120
- ) => Promise<{ [option: string]: any }>)
120
+ ) => { [option: string]: any } | Promise<{ [option: string]: any }>)
121
121
  | { [option: string]: any };
122
122
  /**
123
123
  * The title to use for the generated HTML document
@@ -189,8 +189,8 @@ declare namespace HtmlWebpackPlugin {
189
189
  publicPath: string;
190
190
  js: Array<string>;
191
191
  css: Array<string>;
192
- favicon?: string | undefined;
193
- manifest?: string | undefined;
192
+ favicon?: string;
193
+ manifest?: string;
194
194
  };
195
195
  outputName: string;
196
196
  plugin: HtmlWebpackPlugin;
package/CHANGELOG.md.orig DELETED
@@ -1,376 +0,0 @@
1
- # Change Log
2
-
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
-
5
- <a name="3.0.3"></a>
6
- ## [3.0.3](https://github.com/jantimon/html-webpack-plugin/compare/v3.0.2...v3.0.3) (2018-03-01)
7
-
8
-
9
- <<<<<<< HEAD
10
- =======
11
- ### Refactor
12
-
13
- * **performance:** Reduce the amount of chunk information gathered based on #825 ([06c59a7](https://github.com/jantimon/html-webpack-plugin/commit/06c59a7))
14
-
15
- >>>>>>> chore(release): 3.0.3
16
-
17
- <a name="3.0.2"></a>
18
- ## [3.0.2](https://github.com/jantimon/html-webpack-plugin/compare/v3.0.1...v3.0.2) (2018-03-01)
19
-
20
-
21
- ### Bug Fixes
22
-
23
- * **query-loader:** In case no query is provided, return an empty object. This fixes #727 ([7587754](https://github.com/jantimon/html-webpack-plugin/commit/7587754))
24
-
25
-
26
-
27
- <a name="3.0.1"></a>
28
- ## [3.0.1](https://github.com/jantimon/html-webpack-plugin/compare/v3.0.0...v3.0.1) (2018-03-01)
29
-
30
-
31
- ### Bug Fixes
32
-
33
- * **package:** Remove the extract-text-webpack-plugin peer dependency ([57411a9](https://github.com/jantimon/html-webpack-plugin/commit/57411a9))
34
-
35
- <a name="3.0.0"></a>
36
- ## [3.0.0](https://github.com/jantimon/html-webpack-plugin/compare/v2.30.1...v3.0.0) (2018-28-02)
37
-
38
- ### Features
39
-
40
- * Add support for the new [https://github.com/webpack/tapable](webpack tapable) to be compatible with webpack 4.x
41
- * Remove bluebird dependency
42
-
43
- ### BREAKING CHANGES
44
-
45
- * Similar to webpack 4.x the support for node versions older than 6 are no longer supported
46
-
47
- <a name="2.30.1"></a>
48
- ## 2.30.1
49
-
50
- * Revert part the performance optimization (#723) because of #753.
51
-
52
- <a name="2.30.0"></a>
53
- ## 2.30.0
54
-
55
- * Add manual sort
56
- * Performance improvements (#723)
57
-
58
- <a name="2.29.0"></a>
59
- ## 2.29.0
60
-
61
- * Add support for Webpack 3
62
-
63
- <a name="2.28.0"></a>
64
- ## 2.28.0
65
-
66
- * Backport 3.x void tag for plugin authors
67
-
68
- <a name="2.27.1"></a>
69
- ## 2.27.1
70
-
71
- * Revert 2.25.0 loader resolving
72
-
73
- <a name="2.27.0"></a>
74
- ## 2.27.0
75
-
76
- * Fix a chunksorter webpack 2 issue (#569)
77
- * Fix template path resolving(#542)
78
-
79
- <a name="2.26.0"></a>
80
- ## 2.26.0
81
-
82
- * Allow plugins to add attributes without values to the `<script>` and `<link>` tags
83
-
84
- <a name="2.25.0"></a>
85
- ## 2.25.0
86
-
87
- * Clearer loader output
88
- * Add basic support for webpack 2
89
-
90
- <a name="2.24.1"></a>
91
- ## 2.24.1
92
-
93
- * Hide event deprecated warning of 'applyPluginsAsyncWaterfall' for html-webpack-plugin-after-emit and improve the warning message.
94
-
95
- <a name="2.24.0"></a>
96
- ## 2.24.0
97
-
98
- * Update dependencies
99
- * Add deprecate warning for plugins not returning a result
100
- * Add [path] for favicons
101
-
102
- <a name="2.23.0"></a>
103
- ## 2.23.0
104
-
105
- * Update dependencies
106
- * Stop automated tests for webpack 2 beta because of #401
107
-
108
- <a name="2.22.0"></a>
109
- ## 2.22.0
110
-
111
- * Update dependencies
112
-
113
- <a name="2.21.1"></a>
114
- ## 2.21.1
115
-
116
- * Better error handling (#354)
117
-
118
- <a name="2.21.0"></a>
119
- ## 2.21.0
120
-
121
- * Add `html-webpack-plugin-alter-asset-tags` event to allow plugins to adjust the script/link tags
122
-
123
- <a name="2.20.0"></a>
124
- ## 2.20.0
125
-
126
- * Exclude chunks works now even if combined with dependency sort
127
-
128
- <a name="2.19.0"></a>
129
- ## 2.19.0
130
-
131
- * Add `html-webpack-plugin-alter-chunks` event for custom chunk sorting and interpolation
132
-
133
- <a name="2.18.0"></a>
134
- ## 2.18.0
135
-
136
- * Updated all dependencies
137
-
138
- <a name="2.17.0"></a>
139
- ## 2.17.0
140
-
141
- * Add `type` attribute to `script` element to prevent issues in Safari 9.1.1
142
-
143
- <a name="2.16.2"></a>
144
- ## 2.16.2
145
-
146
- * Fix bug introduced by 2.16.2. Fixes #315
147
-
148
- <a name="2.16.1"></a>
149
- ## 2.16.1
150
-
151
- * Fix hot module replacement for webpack 2.x
152
-
153
- <a name="2.16.0"></a>
154
- ## 2.16.0
155
-
156
- * Add support for dynamic filenames like index[hash].html
157
-
158
- <a name="2.15.0"></a>
159
- ## 2.15.0
160
-
161
- * Add full unit test coverage for the webpack 2 beta version
162
- * For webpack 2 the default sort will be 'dependency' instead of 'id'
163
- * Upgrade dependencies
164
-
165
- <a name="2.14.0"></a>
166
- ## 2.14.0
167
-
168
- * Export publicPath to the template
169
- * Add example for inlining css and js
170
-
171
- <a name="2.13.0"></a>
172
- ## 2.13.0
173
-
174
- * Add support for absolute output file names
175
- * Add support for relative file names outside the output path
176
-
177
- <a name="2.12.0"></a>
178
- ## 2.12.0
179
-
180
- * Basic Webpack 2.x support #225
181
-
182
- <a name="2.11.0"></a>
183
- ## 2.11.0
184
-
185
- * Add `xhtml` option which is turned of by default. When activated it will inject self closed `<link href=".." />` tags instead of unclosed `<link href="..">` tags. https://github.com/ampedandwired/html-webpack-plugin/pull/255
186
- * Add support for webpack placeholders inside the public path e.g. `'/dist/[hash]/'`. https://github.com/ampedandwired/html-webpack-plugin/pull/249
187
-
188
- <a name="2.10.0"></a>
189
- ## 2.10.0
190
-
191
- * Add `hash` field to the chunk object
192
- * Add `compilation` field to the templateParam object (fixes https://github.com/ampedandwired/html-webpack-plugin/issues/237)
193
- * Add `html-webpack-plugin-before-html-generation` event
194
- * Improve error messages
195
-
196
- <a name="2.9.0"></a>
197
- ## 2.9.0
198
-
199
- * Fix favicon path (fixes https://github.com/ampedandwired/html-webpack-plugin/issues/185, https://github.com/ampedandwired/html-webpack-plugin/issues/208, https://github.com/ampedandwired/html-webpack-plugin/pull/215 )
200
-
201
- <a name="2.8.2"></a>
202
- ## 2.8.2
203
-
204
- * Support relative URLs on Windows (fixes https://github.com/ampedandwired/html-webpack-plugin/issues/205 )
205
-
206
- <a name="2.8.1"></a>
207
- ## 2.8.1
208
-
209
- * Caching improvements (fixes https://github.com/ampedandwired/html-webpack-plugin/issues/204 )
210
-
211
- <a name="2.8.0"></a>
212
- ## 2.8.0
213
-
214
- * Add `dependency` mode for `chunksSortMode` to sort chunks based on their dependencies with each other
215
-
216
- <a name="2.7.2"></a>
217
- ## 2.7.2
218
-
219
- * Add support for require in js templates
220
-
221
- <a name="2.7.1"></a>
222
- ## 2.7.1
223
-
224
- * Refactoring
225
- * Fix relative windows path
226
-
227
- <a name="2.6.5"></a>
228
- ## 2.6.5
229
-
230
- * Minor refactoring
231
-
232
- <a name="2.6.4"></a>
233
- ## 2.6.4
234
-
235
- * Fix for `"Uncaught TypeError: __webpack_require__(...) is not a function"`
236
- * Fix incomplete cache modules causing "HtmlWebpackPlugin Error: No source available"
237
- * Fix some issues on Windows
238
-
239
- <a name="2.6.3"></a>
240
- ## 2.6.3
241
-
242
- * Prevent parsing the base template with the html-loader
243
-
244
- <a name="2.6.2"></a>
245
- ## 2.6.2
246
-
247
- * Fix `lodash` resolve error (fixes https://github.com/ampedandwired/html-webpack-plugin/issues/172 )
248
-
249
- <a name="2.6.1"></a>
250
- ## 2.6.1
251
-
252
- * Fix missing module (fixes https://github.com/ampedandwired/html-webpack-plugin/issues/164 )
253
-
254
- <a name="2.6.0"></a>
255
- ## 2.6.0
256
-
257
- * Move compiler to its own file
258
- * Improve error messages
259
- * Fix global HTML_WEBPACK_PLUGIN variable
260
-
261
- <a name="2.5.0"></a>
262
- ## 2.5.0
263
-
264
- * Support `lodash` template's HTML _"escape"_ delimiter (`<%- %>`)
265
- * Fix bluebird warning (fixes https://github.com/ampedandwired/html-webpack-plugin/issues/130 )
266
- * Fix an issue where incomplete cache modules were used
267
-
268
- <a name="2.4.0"></a>
269
- ## 2.4.0
270
-
271
- * Don't recompile if the assets didn't change
272
-
273
- <a name="2.3.0"></a>
274
- ## 2.3.0
275
-
276
- * Add events `html-webpack-plugin-before-html-processing`, `html-webpack-plugin-after-html-processing`, `html-webpack-plugin-after-emit` to allow other plugins to alter the html this plugin executes
277
-
278
- <a name="2.2.0"></a>
279
- ## 2.2.0
280
-
281
- * Inject css and js even if the html file is incomplete (fixes https://github.com/ampedandwired/html-webpack-plugin/issues/135 )
282
- * Update dependencies
283
-
284
- <a name="2.1.0"></a>
285
- ## 2.1.0
286
-
287
- * Synchronize with the stable `@1` version
288
-
289
- <a name="2.0.4"></a>
290
- ## 2.0.4
291
-
292
- * Fix `minify` option
293
- * Fix missing hash interpolation in publicPath
294
-
295
- <a name="2.0.3"></a>
296
- ## 2.0.3
297
-
298
- * Add support for webpack.BannerPlugin
299
-
300
- <a name="2.0.2"></a>
301
- ## 2.0.2
302
-
303
- * Add support for loaders in templates (fixes https://github.com/ampedandwired/html-webpack-plugin/pull/41 )
304
- * Remove `templateContent` option from configuration
305
- * Better error messages
306
- * Update dependencies
307
-
308
-
309
- <a name="1.7.0"></a>
310
- ## 1.7.0
311
-
312
- * Add `chunksSortMode` option to configuration to control how chunks should be sorted before they are included to the html
313
- * Don't insert async chunks into html (fixes https://github.com/ampedandwired/html-webpack-plugin/issues/95 )
314
- * Update dependencies
315
-
316
- <a name="1.6.2"></a>
317
- ## 1.6.2
318
-
319
- * Fix paths on Windows
320
- * Fix missing hash interpolation in publicPath
321
- * Allow only `false` or `object` in `minify` configuration option
322
-
323
- <a name="1.6.1"></a>
324
- ## 1.6.1
325
-
326
- * Add `size` field to the chunk object
327
- * Fix stylesheet `<link>`s being discarded when used with `"inject: 'head'"`
328
- * Update dependencies
329
-
330
- <a name="1.6.0"></a>
331
- ## 1.6.0
332
-
333
- * Support placing templates in subfolders
334
- * Don't include chunks with undefined name (fixes https://github.com/ampedandwired/html-webpack-plugin/pull/60 )
335
- * Don't include async chunks
336
-
337
- <a name="1.5.2"></a>
338
- ## 1.5.2
339
-
340
- * Update dependencies (lodash)
341
-
342
- <a name="1.5.1"></a>
343
- ## 1.5.1
344
-
345
- * Fix error when manifest is specified (fixes https://github.com/ampedandwired/html-webpack-plugin/issues/56 )
346
-
347
- <a name="1.5.0"></a>
348
- ## 1.5.0
349
-
350
- * Allow to inject javascript files into the head of the html page
351
- * Fix error reporting
352
-
353
- <a name="1.4.0"></a>
354
- ## 1.4.0
355
-
356
- * Add `favicon.ico` option
357
- * Add html minifcation
358
-
359
- <a name="1.2.0"></a>
360
- ## 1.2.0
361
-
362
- * Set charset using HTML5 meta attribute
363
- * Reload upon change when using webpack watch mode
364
- * Generate manifest attribute when using
365
- [appcache-webpack-plugin](https://github.com/lettertwo/appcache-webpack-plugin)
366
- * Optionally add webpack hash as a query string to resources included in the HTML
367
- (`hash: true`) for cache busting
368
- * CSS files generated using webpack (for example, by using the
369
- [extract-text-webpack-plugin](https://github.com/webpack/extract-text-webpack-plugin))
370
- are now automatically included into the generated HTML
371
- * More detailed information about the files generated by webpack is now available
372
- to templates in the `o.htmlWebpackPlugin.files` attribute. See readme for more
373
- details. This new attribute deprecates the old `o.htmlWebpackPlugin.assets` attribute.
374
- * The `templateContent` option can now be a function that returns the template string to use
375
- * Expose webpack configuration to templates (`o.webpackConfig`)
376
- * Sort chunks to honour dependencies between them (useful for use with CommonsChunkPlugin).
package/README.md.orig DELETED
@@ -1,603 +0,0 @@
1
- [![npm][npm]][npm-url]
2
- [![node][node]][node-url]
3
- ![npm](https://img.shields.io/npm/dw/html-webpack-plugin.svg)
4
- [![deps][deps]][deps-url]
5
- [![tests][tests]][tests-url]
6
- [![Backers on Open Collective](https://opencollective.com/html-webpack-plugin/backers/badge.svg)](#backers)
7
- [![Sponsors on Open Collective](https://opencollective.com/html-webpack-plugin/sponsors/badge.svg)](#sponsors)
8
-
9
- <div align="center">
10
- <img width="200" height="200" src="https://worldvectorlogo.com/logos/html5.svg">
11
- <a href="https://github.com/webpack/webpack">
12
- <img width="200" height="200"
13
- src="https://webpack.js.org/assets/icon-square-big.svg">
14
- </a>
15
- <div>
16
- <img width="100" height="100" title="Webpack Plugin" src="http://michael-ciniawsky.github.io/postcss-load-plugins/logo.svg">
17
- </div>
18
- <h1>HTML Webpack Plugin</h1>
19
- <p>Plugin that simplifies creation of HTML files to serve your bundles</p>
20
- </div>
21
-
22
- <h2 align="center">Install Beta</h2>
23
-
24
- ```bash
25
- npm i --save-dev html-webpack-plugin@next
26
- ```
27
-
28
- ```bash
29
- yarn add --dev html-webpack-plugin@next
30
- ```
31
-
32
- <h2 align="center">Install Stable</h2>
33
-
34
- ```bash
35
- npm i --save-dev html-webpack-plugin
36
- ```
37
-
38
- ```bash
39
- yarn add --dev html-webpack-plugin
40
- ```
41
-
42
-
43
- This is a [webpack](http://webpack.js.org/) plugin that simplifies creation of HTML files to serve your `webpack` bundles. This is especially useful for `webpack` bundles that include a hash in the filename which changes every compilation. You can either let the plugin generate an HTML file for you, supply
44
- your own template using `lodash` templates or use your own loader.
45
-
46
- <h2 align="center">Sponsors</h2>
47
-
48
- <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>
49
- <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>
50
- <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>
51
- <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>
52
- <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>
53
- <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>
54
- <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>
55
- <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>
56
- <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>
57
- <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>
58
-
59
- Thanks for supporting the ongoing improvements to the html-webpack-plugin!
60
-
61
- <h2 align="center">Zero Config</h2>
62
-
63
- The `html-webpack-plugin` works without configuration.
64
- It's a great addition to the [⚙️ webpack-config-plugins](https://github.com/namics/webpack-config-plugins/blob/master/README.md#zero-config-webpack-dev-server-example).
65
-
66
- <h2 align="center">Plugins</h2>
67
-
68
- The `html-webpack-plugin` provides [hooks](https://github.com/jantimon/html-webpack-plugin#events) to extend it to your needs. There are already some really powerful plugins which can be integrated with zero configuration
69
-
70
- * [webpack-subresource-integrity](https://www.npmjs.com/package/webpack-subresource-integrity) for enhanced asset security
71
- * [appcache-webpack-plugin](https://github.com/lettertwo/appcache-webpack-plugin) for iOS and Android offline usage
72
- * [favicons-webpack-plugin](https://github.com/jantimon/favicons-webpack-plugin) which generates favicons and icons for iOS, Android and desktop browsers
73
- * [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
74
- * [html-webpack-inline-source-plugin](https://github.com/DustinJackson/html-webpack-inline-source-plugin) to inline your assets in the resulting HTML file
75
- * [html-webpack-inline-svg-plugin](https://github.com/thegc/html-webpack-inline-svg-plugin) to inline SVGs in the resulting HTML file.
76
- * [html-webpack-exclude-assets-plugin](https://github.com/jamesjieye/html-webpack-exclude-assets-plugin) for excluding assets using regular expressions
77
- * [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).
78
- * [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 inline them
79
- * [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
80
- * [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'>`
81
- * [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
82
- * [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
83
- * [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>`
84
- * [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.
85
- * [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.
86
- * [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.
87
- * [html-webpack-link-type-plugin](https://github.com/steadyapp/html-webpack-link-type-plugin) adds a configurable mimetype to resources injected as links (such as adding type="text/css" to external stylesheets) for compatibility with "strict mode".
88
-
89
- * [csp-html-webpack-plugin](https://github.com/slackhq/csp-html-webpack-plugin) to add [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) meta tags to the HTML output
90
-
91
-
92
- <h2 align="center">Usage</h2>
93
-
94
- The plugin will generate an HTML5 file for you that includes all your `webpack`
95
- bundles in the body using `script` tags. Just add the plugin to your `webpack`
96
- config as follows:
97
-
98
- **webpack.config.js**
99
- ```js
100
- const HtmlWebpackPlugin = require('html-webpack-plugin')
101
-
102
- module.exports = {
103
- entry: 'index.js',
104
- output: {
105
- path: __dirname + '/dist',
106
- filename: 'index_bundle.js'
107
- },
108
- plugins: [
109
- new HtmlWebpackPlugin()
110
- ]
111
- }
112
- ```
113
-
114
- This will generate a file `dist/index.html` containing the following
115
-
116
- ```html
117
- <!DOCTYPE html>
118
- <html>
119
- <head>
120
- <meta charset="utf-8">
121
- <title>Webpack App</title>
122
- </head>
123
- <body>
124
- <script src="index_bundle.js"></script>
125
- </body>
126
- </html>
127
- ```
128
-
129
- If you have multiple `webpack` entry points, they will all be included with `script` tags in the generated HTML.
130
-
131
- If you have any CSS assets in webpack's output (for example, CSS extracted with the [ExtractTextPlugin](https://github.com/webpack/extract-text-webpack-plugin))
132
- then these will be included with `<link>` tags in the HTML head.
133
-
134
- If you have plugins that make use of it, `html-webpack-plugin` should be ordered first before any of the integrated plugins.
135
-
136
- <h2 align="center">Options</h2>
137
-
138
- You can pass a hash of configuration options to `html-webpack-plugin`.
139
- Allowed values are as follows
140
-
141
- |Name|Type|Default|Description|
142
- |:--:|:--:|:-----:|:----------|
143
- <<<<<<< HEAD
144
- |**`title`**|`{String}`|`Webpack App`|The title to use for the generated HTML document|
145
- |**`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`)|
146
- |**`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|
147
- =======
148
- |**[`title`](#)**|`{String}`|`Webpack App`|The title to use for the generated HTML document|
149
- |**[`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`)|
150
- |**[`template`](#)**|`{String}`|``|`webpack` relative or absolute path to the template. By default it will use `src/index.ejs` if it exists. Please see the [docs](https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md) for details|
151
- >>>>>>> fix: Use src/index.ejs by default if present
152
- |**[`templateParameters`](#)**|`{Boolean\|Object\|Function}`|``| Allows to overwrite the parameters used in the template |
153
- |**`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|
154
- |**`favicon`**|`{String}`|``|Adds the given favicon path to the output HTML|
155
- |**`meta`**|`{Object}`|`{}`|Allows to inject `meta`-tags. E.g. `meta: {viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'}`|
156
- |**`minify`**|`{Boolean\|Object}`|`true` if `mode` is `'production'`, otherwise `false`|Controls if and in what ways the output should be minified. See [minification](#minification) below for more details.|
157
- |**`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|
158
- |**`cache`**|`{Boolean}`|`true`|Emit the file only if it was changed|
159
- |**`showErrors`**|`{Boolean}`|`true`|Errors details will be written into the HTML page|
160
- |**`chunks`**|`{?}`|`?`|Allows you to add only some chunks (e.g only the unit-test chunk)|
161
- |**[`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}`|
162
- |**`excludeChunks`**|`{Array.<string>}`|``|Allows you to skip some chunks (e.g don't add the unit-test chunk)|
163
- |**`xhtml`**|`{Boolean}`|`false`|If `true` render the `link` tags as self-closing (XHTML compliant)|
164
-
165
- Here's an example webpack config illustrating how to use these options
166
-
167
- **webpack.config.js**
168
- ```js
169
- {
170
- entry: 'index.js',
171
- output: {
172
- path: __dirname + '/dist',
173
- filename: 'index_bundle.js'
174
- },
175
- plugins: [
176
- new HtmlWebpackPlugin({
177
- title: 'My App',
178
- filename: 'assets/admin.html'
179
- })
180
- ]
181
- }
182
- ```
183
-
184
- ### Generating Multiple HTML Files
185
-
186
- To generate more than one HTML file, declare the plugin more than
187
- once in your plugins array
188
-
189
- **webpack.config.js**
190
- ```js
191
- {
192
- entry: 'index.js',
193
- output: {
194
- path: __dirname + '/dist',
195
- filename: 'index_bundle.js'
196
- },
197
- plugins: [
198
- new HtmlWebpackPlugin(), // Generates default index.html
199
- new HtmlWebpackPlugin({ // Also generate a test.html
200
- filename: 'test.html',
201
- template: 'src/assets/test.html'
202
- })
203
- ]
204
- }
205
- ```
206
-
207
- ### Writing Your Own Templates
208
-
209
- If the default generated HTML doesn't meet your needs you can supply
210
- your own template. The easiest way is to use the `template` option and pass a custom HTML file.
211
- The html-webpack-plugin will automatically inject all necessary CSS, JS, manifest
212
- and favicon files into the markup.
213
-
214
- Details of other template loaders are [documented here](https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md).
215
-
216
- ```js
217
- plugins: [
218
- new HtmlWebpackPlugin({
219
- title: 'Custom template',
220
- // Load a custom template (lodash by default)
221
- template: 'index.html'
222
- })
223
- ]
224
- ```
225
-
226
- **index.html**
227
- ```html
228
- <!DOCTYPE html>
229
- <html>
230
- <head>
231
- <meta charset="utf-8"/>
232
- <title><%= htmlWebpackPlugin.options.title %></title>
233
- </head>
234
- <body>
235
- </body>
236
- </html>
237
- ```
238
-
239
- If you already have a template loader, you can use it to parse the template.
240
- Please note that this will also happen if you specify the html-loader and use `.html` file as template.
241
-
242
- **webpack.config.js**
243
- ```js
244
- module: {
245
- loaders: [
246
- { test: /\.hbs$/, loader: "handlebars-loader" }
247
- ]
248
- },
249
- plugins: [
250
- new HtmlWebpackPlugin({
251
- title: 'Custom template using Handlebars',
252
- template: 'index.hbs'
253
- })
254
- ]
255
- ```
256
-
257
- You can use the `lodash` syntax out of the box. If the `inject` feature doesn't fit your needs and you want full control over the asset placement use the [default template](https://github.com/jaketrent/html-webpack-template/blob/86f285d5c790a6c15263f5cc50fd666d51f974fd/index.html) of the [html-webpack-template project](https://github.com/jaketrent/html-webpack-template) as a starting point for writing your own.
258
-
259
- The following variables are available in the template:
260
- - `htmlWebpackPlugin`: data specific to this plugin
261
- - `htmlWebpackPlugin.files`: a massaged representation of the
262
- `assetsByChunkName` attribute of webpack's [stats](https://github.com/webpack/docs/wiki/node.js-api#stats)
263
- object. It contains a mapping from entry point name to the bundle filename, eg:
264
- ```json
265
- "htmlWebpackPlugin": {
266
- "files": {
267
- "css": [ "main.css" ],
268
- "js": [ "assets/head_bundle.js", "assets/main_bundle.js"],
269
- "chunks": {
270
- "head": {
271
- "entry": "assets/head_bundle.js",
272
- "css": [ "main.css" ]
273
- },
274
- "main": {
275
- "entry": "assets/main_bundle.js",
276
- "css": []
277
- },
278
- }
279
- }
280
- }
281
- ```
282
- If you've set a publicPath in your webpack config this will be reflected
283
- correctly in this assets hash.
284
-
285
- - `htmlWebpackPlugin.options`: the options hash that was passed to
286
- the plugin. In addition to the options actually used by this plugin,
287
- you can use this hash to pass arbitrary data through to your template.
288
-
289
- - `webpack`: the webpack [stats](https://github.com/webpack/docs/wiki/node.js-api#stats)
290
- object. Note that this is the stats object as it was at the time the HTML template
291
- was emitted and as such may not have the full set of stats that are available
292
- after the webpack run is complete.
293
-
294
- - `webpackConfig`: the webpack configuration that was used for this compilation. This
295
- can be used, for example, to get the `publicPath` (`webpackConfig.output.publicPath`).
296
-
297
- - `compilation`: the webpack [compilation](https://webpack.js.org/api/compilation/) object.
298
- This can be used, for example, to get the contents of processed assets and inline them
299
- directly in the page, through `compilation.assets[...].source()`
300
- (see [the inline template example](examples/inline/template.pug)).
301
-
302
-
303
- ### Filtering Chunks
304
-
305
- To include only certain chunks you can limit the chunks being used
306
-
307
- **webpack.config.js**
308
- ```js
309
- plugins: [
310
- new HtmlWebpackPlugin({
311
- chunks: ['app']
312
- })
313
- ]
314
- ```
315
-
316
- It is also possible to exclude certain chunks by setting the `excludeChunks` option
317
-
318
- **webpack.config.js**
319
- ```js
320
- plugins: [
321
- new HtmlWebpackPlugin({
322
- excludeChunks: [ 'dev-helper' ]
323
- })
324
- ]
325
- ```
326
-
327
- ### Minification
328
-
329
- If the `minify` option is set to `true` (the default when webpack's `mode` is `'production'`),
330
- the generated HTML will be minified using [html-minifier](https://github.com/kangax/html-minifier)
331
- and the following options:
332
-
333
- ```js
334
- {
335
- collapseWhitespace: true,
336
- removeComments: true,
337
- removeRedundantAttributes: true,
338
- removeScriptTypeAttributes: true,
339
- removeStyleLinkTypeAttributes: true,
340
- useShortDoctype: true
341
- }
342
- ```
343
-
344
- To use custom [html-minifier options](https://github.com/kangax/html-minifier#options-quick-reference)
345
- pass an object to `minify` instead. This object will not be merged with the defaults above.
346
-
347
- To disable minification during production mode set the `minify` option to `false`.
348
-
349
- ### Meta Tags
350
-
351
- If the `meta` option is set the html-webpack-plugin will inject meta tags.
352
- For the default template the html-webpack-plugin will already provide a default for the `viewport` meta tag.
353
-
354
- Please take a look at this well maintained list of almost all [possible meta tags](https://github.com/joshbuchea/HEAD#meta).
355
-
356
- #### name/content meta tags
357
-
358
- Most meta tags are configured by setting a `name` and a `content` attribute.
359
- To add those use a key/value pair:
360
-
361
- **webpack.config.js**
362
- ```js
363
- plugins: [
364
- new HtmlWebpackPlugin({
365
- 'meta': {
366
- 'viewport': 'width=device-width, initial-scale=1, shrink-to-fit=no',
367
- // Will generate: <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
368
- 'theme-color': '#4285f4'
369
- // Will generate: <meta name="theme-color" content="#4285f4">
370
- }
371
- })
372
- ]
373
- ```
374
-
375
- #### Simulate http response headers
376
-
377
- The **http-equiv** attribute is essentially used to simulate a HTTP response header.
378
- This format is supported using an object notation which allows you to add any attribute:
379
-
380
- **webpack.config.js**
381
- ```js
382
- plugins: [
383
- new HtmlWebpackPlugin({
384
- 'meta': {
385
- 'Content-Security-Policy': { 'http-equiv': 'Content-Security-Policy', 'content': 'default-src https:' },
386
- // Will generate: <meta http-equiv="Content-Security-Policy" content="default-src https:">
387
- // Which equals to the following http header: `Content-Security-Policy: default-src https:`
388
- 'set-cookie': { 'http-equiv': 'set-cookie', content: 'name=value; expires=date; path=url' },
389
- // Will generate: <meta http-equiv="set-cookie" content="value; expires=date; path=url">
390
- // Which equals to the following http header: `set-cookie: value; expires=date; path=url`
391
- }
392
- })
393
- ]
394
- ```
395
-
396
- ### Long Term Caching
397
-
398
- For long term caching add `contenthash/templatehash` to the filename.
399
-
400
- **Example:**
401
-
402
- ```js
403
- plugins: [
404
- new HtmlWebpackPlugin({
405
- filename: 'index.[contenthash].html'
406
- })
407
- ]
408
- ```
409
-
410
- `contenthash/templatehash` is the hash of the content of the output file.
411
-
412
- Optionally, You can configure like `[<hashType>:contenthash:<digestType>:<length>]`
413
-
414
- * `hashType` - one of `sha1`, `md5`, `sha256`, `sha512` or any other node.js supported hash type
415
- * `digestType` - one of `hex`, `base26`, `base32`, `base36`, `base49`, `base52`, `base58`, `base62`, `base64`
416
- * `maxlength` - maximum length of the generated hash in chars
417
-
418
- **Defaults:** `[md5:contenthash:hex:9999]`
419
-
420
- ### Events
421
-
422
- To allow other [plugins](https://github.com/webpack/docs/wiki/plugins) to alter the HTML this plugin executes
423
- [tapable](https://github.com/webpack/tapable/tree/master) hooks.
424
-
425
- The [lib/hooks.js](https://github.com/jantimon/html-webpack-plugin/blob/master/lib/hooks.js) contains all information
426
- about which values are passed.
427
-
428
- [![Concept flow uml](https://raw.githubusercontent.com/jantimon/html-webpack-plugin/master/flow.png)](https://github.com/jantimon/html-webpack-plugin/blob/master/flow.puml)
429
-
430
- #### `beforeAssetTagGeneration` hook
431
-
432
- ```
433
- AsyncSeriesWaterfallHook<{
434
- assets: {
435
- publicPath: string,
436
- js: Array<{string}>,
437
- css: Array<{string}>,
438
- favicon?: string | undefined,
439
- manifest?: string | undefined
440
- },
441
- outputName: string,
442
- plugin: HtmlWebpackPlugin
443
- }>
444
- ```
445
-
446
- #### `alterAssetTags` hook
447
-
448
- ```
449
- AsyncSeriesWaterfallHook<{
450
- assetTags: {
451
- scripts: Array<HtmlTagObject>,
452
- styles: Array<HtmlTagObject>,
453
- meta: Array<HtmlTagObject>,
454
- },
455
- outputName: string,
456
- plugin: HtmlWebpackPlugin
457
- }>
458
- ```
459
-
460
- #### `alterAssetTagGroups` hook
461
-
462
- ```
463
- AsyncSeriesWaterfallHook<{
464
- headTags: Array<HtmlTagObject | HtmlTagObject>,
465
- bodyTags: Array<HtmlTagObject | HtmlTagObject>,
466
- outputName: string,
467
- plugin: HtmlWebpackPlugin
468
- }>
469
- ```
470
-
471
- #### `afterTemplateExecution` hook
472
-
473
- ```
474
- AsyncSeriesWaterfallHook<{
475
- html: string,
476
- headTags: Array<HtmlTagObject | HtmlTagObject>,
477
- bodyTags: Array<HtmlTagObject | HtmlTagObject>,
478
- outputName: string,
479
- plugin: HtmlWebpackPlugin,
480
- }>
481
- ```
482
-
483
- #### `beforeEmit` hook
484
-
485
- ```
486
- AsyncSeriesWaterfallHook<{
487
- html: string,
488
- outputName: string,
489
- plugin: HtmlWebpackPlugin,
490
- }>
491
- ```
492
-
493
- #### `afterEmit` hook
494
-
495
- ```
496
- AsyncSeriesWaterfallHook<{
497
- outputName: string,
498
- plugin: HtmlWebpackPlugin
499
- }>
500
- ```
501
-
502
- Example implementation: [webpack-subresource-integrity](https://www.npmjs.com/package/webpack-subresource-integrity)
503
-
504
- **plugin.js**
505
- ```js
506
- // If your plugin is direct dependent to the html webpack plugin:
507
- const HtmlWebpackPlugin = require('html-webpack-plugin');
508
- // If your plugin is using html-webpack-plugin as an optional dependency
509
- // you can use https://github.com/tallesl/node-safe-require instead:
510
- const HtmlWebpackPlugin = require('safe-require')('html-webpack-plugin');
511
-
512
- class MyPlugin {
513
- apply (compiler) {
514
- compiler.hooks.compilation.tap('MyPlugin', (compilation) => {
515
- console.log('The compiler is starting a new compilation...')
516
-
517
- // Staic Plugin interface |compilation |HOOK NAME | register listener
518
- HtmlWebpackPlugin.getHooks(compilation).beforeEmit.tapAsync(
519
- 'MyPlugin', // <-- Set a meaningful name here for stacktraces
520
- (data, cb) => {
521
- // Manipulate the content
522
- data.html += 'The Magic Footer'
523
- // Tell webpack to move on
524
- cb(null, data)
525
- }
526
- )
527
- })
528
- }
529
- }
530
-
531
- module.exports = MyPlugin
532
- ```
533
-
534
- **webpack.config.js**
535
- ```js
536
- plugins: [
537
- new MyPlugin({ options: '' })
538
- ]
539
- ```
540
-
541
- Note that the callback must be passed the HtmlWebpackPluginData in order to pass this onto any other plugins listening on the same `beforeEmit` event
542
-
543
- <h2 align="center">Maintainers</h2>
544
-
545
- <table>
546
- <tbody>
547
- <tr>
548
- <td align="center">
549
- <img width="150" height="150"
550
- src="https://avatars3.githubusercontent.com/u/4113649?v=3&s=150">
551
- </br>
552
- <a href="https://github.com/jantimon">Jan Nicklas</a>
553
- </td>
554
- <td align="center">
555
- <img width="150" height="150"
556
- src="https://avatars2.githubusercontent.com/u/4112409?v=3&s=150">
557
- </br>
558
- <a href="https://github.com/mastilver">Thomas Sileghem</a>
559
- </td>
560
- </tr>
561
- <tbody>
562
- </table>
563
-
564
-
565
- ## Backers
566
-
567
- Thank you to all our backers!
568
- If you want to support the project as well [become a sponsor](https://opencollective.com/html-webpack-plugin#sponsor) or a [a backer](https://opencollective.com/html-webpack-plugin#backer).
569
-
570
- <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>
571
- <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>
572
- <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>
573
- <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>
574
- <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>
575
- <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>
576
- <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>
577
- <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>
578
- <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>
579
- <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>
580
-
581
-
582
- ## Contributors
583
-
584
- This project exists thanks to all the people who contribute.
585
-
586
- 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.
587
-
588
- This project uses the [semistandard code style](https://github.com/Flet/semistandard).
589
-
590
- <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>
591
-
592
-
593
- [npm]: https://img.shields.io/npm/v/html-webpack-plugin.svg
594
- [npm-url]: https://npmjs.com/package/html-webpack-plugin
595
-
596
- [node]: https://img.shields.io/node/v/html-webpack-plugin.svg
597
- [node-url]: https://nodejs.org
598
-
599
- [deps]: https://david-dm.org/jantimon/html-webpack-plugin.svg
600
- [deps-url]: https://david-dm.org/jantimon/html-webpack-plugin
601
-
602
- [tests]: http://img.shields.io/travis/jantimon/html-webpack-plugin.svg
603
- [tests-url]: https://travis-ci.org/jantimon/html-webpack-plugin