html-webpack-plugin 4.0.0-beta.13 → 4.0.0-beta.5

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 CHANGED
@@ -77,7 +77,6 @@ The `html-webpack-plugin` provides [hooks](https://github.com/jantimon/html-webp
77
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
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
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
- * [html-webpack-injector](https://github.com/thearchitgarg/html-webpack-injector) to inject chunks in `head` or `body` (different locations ) of same html document.
81
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'>`
82
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
83
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
@@ -86,8 +85,8 @@ The `html-webpack-plugin` provides [hooks](https://github.com/jantimon/html-webp
86
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.
87
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.
88
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
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
- * [webpack-nomodule-plugin](https://github.com/swimmadude66/webpack-nomodule-plugin) allows you to add a `nomodule` attribute to specific injected scripts, which prevents the scripts from being loaded by newer browsers. Good for limiting loads of polyfills.
91
90
 
92
91
 
93
92
  <h2 align="center">Usage</h2>
@@ -129,7 +128,7 @@ This will generate a file `dist/index.html` containing the following
129
128
 
130
129
  If you have multiple `webpack` entry points, they will all be included with `script` tags in the generated HTML.
131
130
 
132
- If you have any CSS assets in webpack's output (for example, CSS extracted with the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin))
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))
133
132
  then these will be included with `<link>` tags in the HTML head.
134
133
 
135
134
  If you have plugins that make use of it, `html-webpack-plugin` should be ordered first before any of the integrated plugins.
@@ -141,23 +140,21 @@ Allowed values are as follows
141
140
 
142
141
  |Name|Type|Default|Description|
143
142
  |:--:|:--:|:-----:|:----------|
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` 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|
147
- |**`templateParameters`**|`{Boolean\|Object\|Function}`|``| Allows to overwrite the parameters used in the template - see [example](https://github.com/jantimon/html-webpack-plugin/tree/master/examples/template-parameters) |
148
- |**`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 - see the [inject:false example](https://github.com/jantimon/html-webpack-plugin/tree/master/examples/custom-insertion-position)|
149
- |**`scriptLoading`**|`{'blocking'\|'defer'}`|`'blocking'`| Modern browsers support non blocking javascript loading (`'defer'`) to improve the page startup performance. |
150
- |**`favicon`**|`{String}`|``|Adds the given favicon path to the output HTML|
151
- |**`meta`**|`{Object}`|`{}`|Allows to inject `meta`-tags. E.g. `meta: {viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'}`|
152
- |**`base`**|`{Object\|String\|false}`|`false`|Inject a [`base`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) tag. E.g. `base: "https://example.com/path/page.html`|
153
- |**`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.|
154
- |**`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|
155
- |**`cache`**|`{Boolean}`|`true`|Emit the file only if it was changed|
156
- |**`showErrors`**|`{Boolean}`|`true`|Errors details will be written into the HTML page|
157
- |**`chunks`**|`{?}`|`?`|Allows you to add only some chunks (e.g only the unit-test chunk)|
143
+ |**[`title`](#)**|`{String}`|`Webpack App`|The title to use for the generated HTML document|
144
+ |**[`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`)|
145
+ |**[`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|
146
+ |**[`templateParameters`](#)**|`{Boolean\|Object\|Function}`|``| Allows to overwrite the parameters used in the template |
147
+ |**[`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|
148
+ |**[`favicon`](#)**|`{String}`|``|Adds the given favicon path to the output HTML|
149
+ |**[`meta`](#)**|`{Object}`|`{}`|Allows to inject `meta`-tags. E.g. `meta: {viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'}`|
150
+ |**[`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.|
151
+ |**[`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|
152
+ |**[`cache`](#)**|`{Boolean}`|`true`|Emit the file only if it was changed|
153
+ |**[`showErrors`](#)**|`{Boolean}`|`true`|Errors details will be written into the HTML page|
154
+ |**[`chunks`](#)**|`{?}`|`?`|Allows you to add only some chunks (e.g only the unit-test chunk)|
158
155
  |**[`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}`|
159
- |**`excludeChunks`**|`{Array.<string>}`|``|Allows you to skip some chunks (e.g don't add the unit-test chunk)|
160
- |**`xhtml`**|`{Boolean}`|`false`|If `true` render the `link` tags as self-closing (XHTML compliant)|
156
+ |**[`excludeChunks`](#)**|`{Array.<string>}`|``|Allows you to skip some chunks (e.g don't add the unit-test chunk)|
157
+ |**[`xhtml`](#)**|`{Boolean}`|`false`|If `true` render the `link` tags as self-closing (XHTML compliant)|
161
158
 
162
159
  Here's an example webpack config illustrating how to use these options
163
160
 
@@ -324,7 +321,7 @@ plugins: [
324
321
  ### Minification
325
322
 
326
323
  If the `minify` option is set to `true` (the default when webpack's `mode` is `'production'`),
327
- the generated HTML will be minified using [html-minifier-terser](https://github.com/DanielRuf/html-minifier-terser)
324
+ the generated HTML will be minified using [html-minifier](https://github.com/kangax/html-minifier)
328
325
  and the following options:
329
326
 
330
327
  ```js
@@ -338,10 +335,10 @@ and the following options:
338
335
  }
339
336
  ```
340
337
 
341
- To use custom [html-minifier options](https://github.com/DanielRuf/html-minifier-terser#options-quick-reference)
338
+ To use custom [html-minifier options](https://github.com/kangax/html-minifier#options-quick-reference)
342
339
  pass an object to `minify` instead. This object will not be merged with the defaults above.
343
340
 
344
- To disable minification during production mode set the `minify` option to `false`.
341
+ To disable minifcation during production mode set the `minify` option to `false`.
345
342
 
346
343
  ### Meta Tags
347
344
 
@@ -390,39 +387,6 @@ plugins: [
390
387
  ]
391
388
  ```
392
389
 
393
- ### Base Tag
394
-
395
- When the `base` option is used,
396
- html-webpack-plugin will inject a [base tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base).
397
- By default, a base tag will not be injected.
398
-
399
- The following two are identical and will both insert `<base href="http://example.com/some/page.html">`:
400
-
401
- ```js
402
- new HtmlWebpackPlugin({
403
- 'base': 'http://example.com/some/page.html'
404
- })
405
- ```
406
-
407
- ```js
408
- new HtmlWebpackPlugin({
409
- 'base': { 'href': 'http://example.com/some/page.html' }
410
- })
411
- ```
412
-
413
- The `target` can be specified with the corresponding key:
414
-
415
- ```js
416
- new HtmlWebpackPlugin({
417
- 'base': {
418
- 'href': 'http://example.com/some/page.html',
419
- 'target': '_blank'
420
- }
421
- })
422
- ```
423
-
424
- which will inject the element `<base href="http://example.com/some/page.html" target="_blank">`.
425
-
426
390
  ### Long Term Caching
427
391
 
428
392
  For long term caching add `contenthash/templatehash` to the filename.
@@ -544,7 +508,7 @@ class MyPlugin {
544
508
  compiler.hooks.compilation.tap('MyPlugin', (compilation) => {
545
509
  console.log('The compiler is starting a new compilation...')
546
510
 
547
- // Static Plugin interface |compilation |HOOK NAME | register listener
511
+ // Staic Plugin interface |compilation |HOOK NAME | register listener
548
512
  HtmlWebpackPlugin.getHooks(compilation).beforeEmit.tapAsync(
549
513
  'MyPlugin', // <-- Set a meaningful name here for stacktraces
550
514
  (data, cb) => {
package/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  // @ts-check
2
2
  // Import types
3
- /** @typedef {import("./typings").HtmlTagObject} HtmlTagObject */
4
- /** @typedef {import("./typings").Options} HtmlWebpackOptions */
5
- /** @typedef {import("./typings").ProcessedOptions} ProcessedHtmlWebpackOptions */
6
- /** @typedef {import("./typings").TemplateParameter} TemplateParameter */
3
+ /* eslint-disable */
4
+ /// <reference path="./typings.d.ts" />
5
+ /* eslint-enable */
7
6
  /** @typedef {import("webpack/lib/Compiler.js")} WebpackCompiler */
8
7
  /** @typedef {import("webpack/lib/Compilation.js")} WebpackCompilation */
9
8
  'use strict';
@@ -29,37 +28,35 @@ const fsReadFileAsync = promisify(fs.readFile);
29
28
 
30
29
  class HtmlWebpackPlugin {
31
30
  /**
32
- * @param {HtmlWebpackOptions} [options]
31
+ * @param {Partial<HtmlWebpackPluginOptions>} [options]
33
32
  */
34
33
  constructor (options) {
35
- /** @type {HtmlWebpackOptions} */
34
+ /** @type {Partial<HtmlWebpackPluginOptions>} */
36
35
  const userOptions = options || {};
37
36
 
38
37
  // Default options
39
- /** @type {ProcessedHtmlWebpackOptions} */
38
+ /** @type {HtmlWebpackPluginOptions} */
40
39
  const defaultOptions = {
41
- template: 'auto',
40
+ template: path.join(__dirname, 'default_index.ejs'),
42
41
  templateContent: false,
43
42
  templateParameters: templateParametersGenerator,
44
43
  filename: 'index.html',
45
44
  hash: false,
46
- inject: userOptions.scriptLoading !== 'defer' ? 'body' : 'head',
47
- scriptLoading: 'blocking',
45
+ inject: true,
48
46
  compile: true,
49
47
  favicon: false,
50
- minify: 'auto',
48
+ minify: undefined,
51
49
  cache: true,
52
50
  showErrors: true,
53
51
  chunks: 'all',
54
52
  excludeChunks: [],
55
53
  chunksSortMode: 'auto',
56
54
  meta: {},
57
- base: false,
58
55
  title: 'Webpack App',
59
56
  xhtml: false
60
57
  };
61
58
 
62
- /** @type {ProcessedHtmlWebpackOptions} */
59
+ /** @type {HtmlWebpackPluginOptions} */
63
60
  this.options = Object.assign(defaultOptions, userOptions);
64
61
 
65
62
  // Default metaOptions if no template is provided
@@ -114,8 +111,7 @@ class HtmlWebpackPlugin {
114
111
  const isProductionLikeMode = compiler.options.mode === 'production' || !compiler.options.mode;
115
112
 
116
113
  const minify = this.options.minify;
117
- if (minify === true || (minify === 'auto' && isProductionLikeMode)) {
118
- /** @type { import('html-minifier').Options } */
114
+ if (minify === true || (minify === undefined && isProductionLikeMode)) {
119
115
  this.options.minify = {
120
116
  // https://github.com/kangax/html-minifier#options-quick-reference
121
117
  collapseWhitespace: true,
@@ -220,12 +216,11 @@ class HtmlWebpackPlugin {
220
216
  // Turn the js and css paths into grouped HtmlTagObjects
221
217
  const assetTagGroupsPromise = assetsPromise
222
218
  // And allow third-party-plugin authors to reorder and change the assetTags before they are grouped
223
- .then(({ assets }) => getHtmlWebpackPluginHooks(compilation).alterAssetTags.promise({
219
+ .then(({assets}) => getHtmlWebpackPluginHooks(compilation).alterAssetTags.promise({
224
220
  assetTags: {
225
221
  scripts: self.generatedScriptTags(assets.js),
226
222
  styles: self.generateStyleTags(assets.css),
227
223
  meta: [
228
- ...self.generateBaseTag(self.options.base),
229
224
  ...self.generatedMetaTags(self.options.meta),
230
225
  ...self.generateFaviconTags(assets.favicon)
231
226
  ]
@@ -233,7 +228,7 @@ class HtmlWebpackPlugin {
233
228
  outputName: childCompilationOutputName,
234
229
  plugin: self
235
230
  }))
236
- .then(({ assetTags }) => {
231
+ .then(({assetTags}) => {
237
232
  // Inject scripts to body unless it set explictly to head
238
233
  const scriptTarget = self.options.inject === 'head' ? 'head' : 'body';
239
234
  // Group assets to `head` and `body` tag arrays
@@ -268,17 +263,17 @@ class HtmlWebpackPlugin {
268
263
  const injectedHtmlPromise = Promise.all([assetTagGroupsPromise, templateExectutionPromise])
269
264
  // Allow plugins to change the html before assets are injected
270
265
  .then(([assetTags, html]) => {
271
- const pluginArgs = { html, headTags: assetTags.headTags, bodyTags: assetTags.bodyTags, plugin: self, outputName: childCompilationOutputName };
266
+ const pluginArgs = {html, headTags: assetTags.headTags, bodyTags: assetTags.bodyTags, plugin: self, outputName: childCompilationOutputName};
272
267
  return getHtmlWebpackPluginHooks(compilation).afterTemplateExecution.promise(pluginArgs);
273
268
  })
274
- .then(({ html, headTags, bodyTags }) => {
275
- return self.postProcessHtml(html, assets, { headTags, bodyTags });
269
+ .then(({html, headTags, bodyTags}) => {
270
+ return self.postProcessHtml(html, assets, {headTags, bodyTags});
276
271
  });
277
272
 
278
273
  const emitHtmlPromise = injectedHtmlPromise
279
274
  // Allow plugins to change the html after assets are injected
280
275
  .then((html) => {
281
- const pluginArgs = { html, plugin: self, outputName: childCompilationOutputName };
276
+ const pluginArgs = {html, plugin: self, outputName: childCompilationOutputName};
282
277
  return getHtmlWebpackPluginHooks(compilation).beforeEmit.promise(pluginArgs)
283
278
  .then(result => result.html);
284
279
  })
@@ -334,8 +329,8 @@ class HtmlWebpackPlugin {
334
329
  // To extract the result during the evaluation this part has to be removed.
335
330
  source = source.replace('var HTML_WEBPACK_PLUGIN_RESULT =', '');
336
331
  const template = this.options.template.replace(/^.+!/, '').replace(/\?.+$/, '');
337
- const vmContext = vm.createContext(_.extend({ HTML_WEBPACK_PLUGIN: true, require: require }, global));
338
- const vmScript = new vm.Script(source, { filename: template });
332
+ const vmContext = vm.createContext(_.extend({HTML_WEBPACK_PLUGIN: true, require: require}, global));
333
+ const vmScript = new vm.Script(source, {filename: template});
339
334
  // Evaluate code and cast to string
340
335
  let newSource;
341
336
  try {
@@ -372,30 +367,21 @@ class HtmlWebpackPlugin {
372
367
  if (templateParameters === false) {
373
368
  return Promise.resolve({});
374
369
  }
375
- if (typeof templateParameters !== 'function' && typeof templateParameters !== 'object') {
376
- throw new Error('templateParameters has to be either a function or an object');
370
+ if (typeof templateParameters === 'function') {
371
+ return Promise
372
+ .resolve()
373
+ .then(() => templateParameters(compilation, assets, assetTags, this.options));
377
374
  }
378
- const templateParameterFunction = typeof templateParameters === 'function'
379
- // A custom function can overwrite the entire template parameter preparation
380
- ? templateParameters
381
- // If the template parameters is an object merge it with the default values
382
- : (compilation, assets, assetTags, options) => Object.assign({},
383
- templateParametersGenerator(compilation, assets, assetTags, options),
384
- templateParameters
385
- );
386
- const preparedAssetTags = {
387
- headTags: this.prepareAssetTagGroupForRendering(assetTags.headTags),
388
- bodyTags: this.prepareAssetTagGroupForRendering(assetTags.bodyTags)
389
- };
390
- return Promise
391
- .resolve()
392
- .then(() => templateParameterFunction(compilation, assets, preparedAssetTags, this.options));
375
+ if (typeof templateParameters === 'object') {
376
+ return Promise.resolve(templateParameters);
377
+ }
378
+ throw new Error('templateParameters has to be either a function or an object');
393
379
  }
394
380
 
395
381
  /**
396
382
  * This function renders the actual html by executing the template function
397
383
  *
398
- * @param {(templateParameters) => string | Promise<string>} templateFunction
384
+ * @param {(templatePArameters) => string | Promise<string>} templateFunction
399
385
  * @param {{
400
386
  publicPath: string,
401
387
  js: Array<string>,
@@ -447,7 +433,9 @@ class HtmlWebpackPlugin {
447
433
  const htmlAfterInjection = this.options.inject
448
434
  ? this.injectAssetsIntoHtml(html, assets, assetTags)
449
435
  : html;
450
- const htmlAfterMinification = this.minifyHtml(htmlAfterInjection);
436
+ const htmlAfterMinification = this.options.minify
437
+ ? require('html-minifier').minify(htmlAfterInjection, this.options.minify)
438
+ : htmlAfterInjection;
451
439
  return Promise.resolve(htmlAfterMinification);
452
440
  }
453
441
 
@@ -557,7 +545,7 @@ class HtmlWebpackPlugin {
557
545
  * if a path publicPath is set in the current webpack config use it otherwise
558
546
  * fallback to a realtive path
559
547
  */
560
- const webpackPublicPath = compilation.mainTemplate.getPublicPath({ hash: compilationHash });
548
+ const webpackPublicPath = compilation.mainTemplate.getPublicPath({hash: compilationHash});
561
549
  const isPublicPathDefined = webpackPublicPath.trim() !== '';
562
550
  let publicPath = isPublicPathDefined
563
551
  // If a hard coded public path exists use it
@@ -582,7 +570,7 @@ class HtmlWebpackPlugin {
582
570
  const assets = {
583
571
  // The public path
584
572
  publicPath: publicPath,
585
- // Will contain all js and mjs files
573
+ // Will contain all js files
586
574
  js: [],
587
575
  // Will contain all css files
588
576
  css: [],
@@ -597,9 +585,9 @@ class HtmlWebpackPlugin {
597
585
  assets.manifest = this.appendHash(assets.manifest, compilationHash);
598
586
  }
599
587
 
600
- // Extract paths to .js, .mjs and .css files from the current compilation
588
+ // Extract paths to .js and .css files from the current compilation
601
589
  const entryPointPublicPathMap = {};
602
- const extensionRegexp = /\.(css|js|mjs)(\?|$)/;
590
+ const extensionRegexp = /\.(css|js)(\?|$)/;
603
591
  for (let i = 0; i < entryNames.length; i++) {
604
592
  const entryName = entryNames[i];
605
593
  const entryPointFiles = compilation.entrypoints.get(entryName).getFiles();
@@ -608,7 +596,7 @@ class HtmlWebpackPlugin {
608
596
  // E.g. bundle.js -> /bundle.js?hash
609
597
  const entryPointPublicPaths = entryPointFiles
610
598
  .map(chunkFile => {
611
- const entryPointPublicPath = publicPath + this.urlencodePath(chunkFile);
599
+ const entryPointPublicPath = publicPath + chunkFile;
612
600
  return this.options.hash
613
601
  ? this.appendHash(entryPointPublicPath, compilationHash)
614
602
  : entryPointPublicPath;
@@ -616,7 +604,7 @@ class HtmlWebpackPlugin {
616
604
 
617
605
  entryPointPublicPaths.forEach((entryPointPublicPath) => {
618
606
  const extMatch = extensionRegexp.exec(entryPointPublicPath);
619
- // Skip if the public path is not a .css, .mjs or .js file
607
+ // Skip if the public path is not a .css or .js file
620
608
  if (!extMatch) {
621
609
  return;
622
610
  }
@@ -626,8 +614,8 @@ class HtmlWebpackPlugin {
626
614
  return;
627
615
  }
628
616
  entryPointPublicPathMap[entryPointPublicPath] = true;
629
- // ext will contain .js or .css, because .mjs recognizes as .js
630
- const ext = extMatch[1] === 'mjs' ? 'js' : extMatch[1];
617
+ // ext will contain .js or .css
618
+ const ext = extMatch[1];
631
619
  assets[ext].push(entryPointPublicPath);
632
620
  });
633
621
  }
@@ -640,7 +628,7 @@ class HtmlWebpackPlugin {
640
628
  *
641
629
  * @param {string|false} faviconFilePath
642
630
  * @param {WebpackCompilation} compilation
643
- * @param {string} publicPath
631
+ * @parma {string} publicPath
644
632
  * @returns {Promise<string|undefined>}
645
633
  */
646
634
  getFaviconPublicPath (faviconFilePath, compilation, publicPath) {
@@ -702,7 +690,6 @@ class HtmlWebpackPlugin {
702
690
  tagName: 'script',
703
691
  voidTag: false,
704
692
  attributes: {
705
- defer: this.options.scriptLoading !== 'blocking',
706
693
  src: scriptAsset
707
694
  }
708
695
  }));
@@ -724,28 +711,6 @@ class HtmlWebpackPlugin {
724
711
  }));
725
712
  }
726
713
 
727
- /**
728
- * Generate an optional base tag
729
- * @param { false
730
- | string
731
- | {[attributeName: string]: string} // attributes e.g. { href:"http://example.com/page.html" target:"_blank" }
732
- } baseOption
733
- * @returns {Array<HtmlTagObject>}
734
- */
735
- generateBaseTag (baseOption) {
736
- if (baseOption === false) {
737
- return [];
738
- } else {
739
- return [{
740
- tagName: 'base',
741
- voidTag: true,
742
- attributes: (typeof baseOption === 'string') ? {
743
- href: baseOption
744
- } : baseOption
745
- }];
746
- }
747
- }
748
-
749
714
  /**
750
715
  * Generate all meta tags for the given meta configuration
751
716
  * @param {false | {
@@ -838,28 +803,6 @@ class HtmlWebpackPlugin {
838
803
  return result;
839
804
  }
840
805
 
841
- /**
842
- * Add toString methods for easier rendering
843
- * inside the template
844
- *
845
- * @param {Array<HtmlTagObject>} assetTagGroup
846
- * @returns {Array<HtmlTagObject>}
847
- */
848
- prepareAssetTagGroupForRendering (assetTagGroup) {
849
- const xhtml = this.options.xhtml;
850
- const preparedTags = assetTagGroup.map((assetTag) => {
851
- const copiedAssetTag = Object.assign({}, assetTag);
852
- copiedAssetTag.toString = function () {
853
- return htmlTagObjectToString(this, xhtml);
854
- };
855
- return copiedAssetTag;
856
- });
857
- preparedTags.toString = function () {
858
- return this.join('');
859
- };
860
- return preparedTags;
861
- }
862
-
863
806
  /**
864
807
  * Injects the assets into the given html string
865
808
  *
@@ -931,30 +874,14 @@ class HtmlWebpackPlugin {
931
874
  return url + (url.indexOf('?') === -1 ? '?' : '&') + hash;
932
875
  }
933
876
 
934
- /**
935
- * Encode each path component using `encodeURIComponent` as files can contain characters
936
- * which needs special encoding in URLs like `+ `.
937
- *
938
- * @param {string} filePath
939
- */
940
- urlencodePath (filePath) {
941
- return filePath.split('/').map(encodeURIComponent).join('/');
942
- }
943
-
944
877
  /**
945
878
  * Helper to return the absolute template path with a fallback loader
946
879
  * @param {string} template
947
- * The path to the template e.g. './index.html'
880
+ * The path to the tempalate e.g. './index.html'
948
881
  * @param {string} context
949
882
  * The webpack base resolution path for relative paths e.g. process.cwd()
950
883
  */
951
884
  getFullTemplatePath (template, context) {
952
- if (template === 'auto') {
953
- template = path.resolve(context, 'src/index.ejs');
954
- if (!fs.existsSync(template)) {
955
- template = path.join(__dirname, 'default_index.ejs');
956
- }
957
- }
958
885
  // If the template doesn't use a loader use the lodash template loader
959
886
  if (template.indexOf('!') === -1) {
960
887
  template = require.resolve('./lib/loader.js') + '!' + path.resolve(context, template);
@@ -965,38 +892,6 @@ class HtmlWebpackPlugin {
965
892
  (match, prefix, filepath, postfix) => prefix + path.resolve(filepath) + postfix);
966
893
  }
967
894
 
968
- /**
969
- * Minify the given string using html-minifier-terser
970
- *
971
- * As this is a breaking change to html-webpack-plugin 3.x
972
- * provide an extended error message to explain how to get back
973
- * to the old behaviour
974
- *
975
- * @param {string} html
976
- */
977
- minifyHtml (html) {
978
- if (typeof this.options.minify !== 'object') {
979
- return html;
980
- }
981
- try {
982
- return require('html-minifier-terser').minify(html, this.options.minify);
983
- } catch (e) {
984
- const isParseError = String(e.message).indexOf('Parse Error') === 0;
985
- if (isParseError) {
986
- e.message = 'html-webpack-plugin could not minify the generated output.\n' +
987
- 'In production mode the html minifcation is enabled by default.\n' +
988
- 'If you are not generating a valid html output please disable it manually.\n' +
989
- 'You can do so by adding the following setting to your HtmlWebpackPlugin config:\n|\n|' +
990
- ' minify: false\n|\n' +
991
- 'See https://github.com/jantimon/html-webpack-plugin#options for details.\n\n' +
992
- 'For parser dedicated bugs please create an issue here:\n' +
993
- 'https://danielruf.github.io/html-minifier-terser/' +
994
- '\n' + e.message;
995
- }
996
- throw e;
997
- }
998
- }
999
-
1000
895
  /**
1001
896
  * Helper to return a sorted unique array of all asset files out of the
1002
897
  * asset object
@@ -1025,10 +920,17 @@ class HtmlWebpackPlugin {
1025
920
  headTags: HtmlTagObject[],
1026
921
  bodyTags: HtmlTagObject[]
1027
922
  }} assetTags
1028
- * @param {ProcessedHtmlWebpackOptions} options
1029
- * @returns {TemplateParameter}
923
+ * @param {HtmlWebpackPluginOptions} options
924
+ * @returns {HtmlWebpackPluginTemplateParameter}
1030
925
  */
1031
926
  function templateParametersGenerator (compilation, assets, assetTags, options) {
927
+ const xhtml = options.xhtml;
928
+ assetTags.headTags.toString = function () {
929
+ return this.map((assetTagObject) => htmlTagObjectToString(assetTagObject, xhtml)).join('');
930
+ };
931
+ assetTags.bodyTags.toString = function () {
932
+ return this.map((assetTagObject) => htmlTagObjectToString(assetTagObject, xhtml)).join('');
933
+ };
1032
934
  return {
1033
935
  compilation: compilation,
1034
936
  webpackConfig: compilation.options,
package/lib/compiler.js CHANGED
@@ -179,7 +179,7 @@ class HtmlWebpackChildCompiler {
179
179
  */
180
180
  function extractHelperFilesFromCompilation (mainCompilation, childCompilation, filename, childEntryChunks) {
181
181
  const helperAssetNames = childEntryChunks.map((entryChunk, index) => {
182
- return mainCompilation.mainTemplate.getAssetPath(filename, {
182
+ return mainCompilation.mainTemplate.hooks.assetPath.call(filename, {
183
183
  hash: childCompilation.hash,
184
184
  chunk: entryChunk,
185
185
  name: `HtmlWebpackPlugin_${index}`
@@ -261,7 +261,7 @@ function compileTemplate (templatePath, outputFilename, mainCompilation) {
261
261
  if (!compiledTemplates[templatePath]) console.log(Object.keys(compiledTemplates), templatePath);
262
262
  const compiledTemplate = compiledTemplates[templatePath];
263
263
  // Replace [hash] placeholders in filename
264
- const outputName = mainCompilation.mainTemplate.getAssetPath(outputFilename, {
264
+ const outputName = mainCompilation.mainTemplate.hooks.assetPath.call(outputFilename, {
265
265
  hash: compiledTemplate.hash,
266
266
  chunk: compiledTemplate.entry
267
267
  });
package/lib/hooks.js CHANGED
@@ -1,5 +1,7 @@
1
1
  // @ts-check
2
- /** @typedef {import("../typings").Hooks} HtmlWebpackPluginHooks */
2
+ /* eslint-disable */
3
+ /// <reference path="../typings.d.ts" />
4
+ /* eslint-enable */
3
5
  'use strict';
4
6
  /**
5
7
  * This file provides access to all public htmlWebpackPlugin hooks
@@ -10,9 +12,10 @@
10
12
 
11
13
  const AsyncSeriesWaterfallHook = require('tapable').AsyncSeriesWaterfallHook;
12
14
 
13
- // The following is the API definition for all available hooks
14
- // For the TypeScript definition, see the Hooks type in typings.d.ts
15
- /**
15
+ // The following typedef holds the API definition for all available hooks
16
+ // to allow easier access when using ts-check or typescript inside plugins
17
+ /** @typedef {{
18
+
16
19
  beforeAssetTagGeneration:
17
20
  AsyncSeriesWaterfallHook<{
18
21
  assets: {
@@ -25,6 +28,7 @@ const AsyncSeriesWaterfallHook = require('tapable').AsyncSeriesWaterfallHook;
25
28
  outputName: string,
26
29
  plugin: HtmlWebpackPlugin
27
30
  }>,
31
+
28
32
  alterAssetTags:
29
33
  AsyncSeriesWaterfallHook<{
30
34
  assetTags: {
@@ -35,6 +39,7 @@ const AsyncSeriesWaterfallHook = require('tapable').AsyncSeriesWaterfallHook;
35
39
  outputName: string,
36
40
  plugin: HtmlWebpackPlugin
37
41
  }>,
42
+
38
43
  alterAssetTagGroups:
39
44
  AsyncSeriesWaterfallHook<{
40
45
  headTags: Array<HtmlTagObject | HtmlTagObject>,
@@ -42,6 +47,7 @@ const AsyncSeriesWaterfallHook = require('tapable').AsyncSeriesWaterfallHook;
42
47
  outputName: string,
43
48
  plugin: HtmlWebpackPlugin
44
49
  }>,
50
+
45
51
  afterTemplateExecution:
46
52
  AsyncSeriesWaterfallHook<{
47
53
  html: string,
@@ -50,18 +56,22 @@ const AsyncSeriesWaterfallHook = require('tapable').AsyncSeriesWaterfallHook;
50
56
  outputName: string,
51
57
  plugin: HtmlWebpackPlugin,
52
58
  }>,
59
+
53
60
  beforeEmit:
54
61
  AsyncSeriesWaterfallHook<{
55
62
  html: string,
56
63
  outputName: string,
57
64
  plugin: HtmlWebpackPlugin,
58
65
  }>,
66
+
59
67
  afterEmit:
60
68
  AsyncSeriesWaterfallHook<{
61
69
  outputName: string,
62
70
  plugin: HtmlWebpackPlugin
63
- }>
64
- */
71
+ }>,
72
+
73
+ }} HtmlWebpackPluginHooks
74
+ */
65
75
 
66
76
  /**
67
77
  * @type {WeakMap<WebpackCompilation, HtmlWebpackPluginHooks>}}
package/lib/html-tags.js CHANGED
@@ -1,5 +1,7 @@
1
1
  // @ts-check
2
- /** @typedef {import("../typings").HtmlTagObject} HtmlTagObject */
2
+ /* eslint-disable */
3
+ /// <reference path="../typings.d.ts" />
4
+ /* eslint-enable */
3
5
  /**
4
6
  * @file
5
7
  * This file provides to helper to create html as a object repesentation as
package/lib/loader.js CHANGED
@@ -21,12 +21,11 @@ module.exports = function (source) {
21
21
  return source;
22
22
  }
23
23
 
24
- // The following part renders the template with lodash as a minimalistic loader
24
+ // The following part renders the template with lodash as aminimalistic loader
25
25
  //
26
26
  const template = _.template(source, _.defaults(options, { interpolate: /<%=([\s\S]+?)%>/g, variable: 'data' }));
27
- // Use __non_webpack_require__ to enforce using the native nodejs require
28
- // during template execution
29
- return 'var _ = __non_webpack_require__(' + JSON.stringify(require.resolve('lodash')) + ');' +
27
+ // Require !!lodash - using !! will disable all loaders (e.g. babel)
28
+ return 'var _ = require(' + loaderUtils.stringifyRequest(this, '!!' + require.resolve('lodash')) + ');' +
30
29
  'module.exports = function (templateParams) { with(templateParams) {' +
31
30
  // Execute the lodash template
32
31
  'return (' + template.source + ')();' +
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "html-webpack-plugin",
3
- "version": "4.0.0-beta.13",
3
+ "version": "4.0.0-beta.5",
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)",
7
7
  "main": "index.js",
8
- "types": "typings.d.ts",
9
8
  "files": [
10
9
  "lib/",
11
10
  "index.js",
@@ -28,35 +27,34 @@
28
27
  ]
29
28
  },
30
29
  "devDependencies": {
31
- "@types/html-minifier": "3.5.3",
32
30
  "@types/loader-utils": "1.1.3",
33
- "@types/node": "11.13.9",
31
+ "@types/node": "10.11.4",
34
32
  "@types/tapable": "1.0.4",
35
- "appcache-webpack-plugin": "1.4.0",
36
- "commitizen": "4.0.3",
37
- "css-loader": "2.1.1",
33
+ "appcache-webpack-plugin": "^1.4.0",
34
+ "commitizen": "3.0.2",
35
+ "css-loader": "^1.0.0",
38
36
  "cz-conventional-changelog": "2.1.0",
39
- "dir-compare": "1.7.2",
40
- "file-loader": "3.0.1",
41
- "html-loader": "0.5.5",
42
- "jest": "24.7.1",
43
- "mini-css-extract-plugin": "0.6.0",
37
+ "dir-compare": "1.4.0",
38
+ "file-loader": "^2.0.0",
39
+ "html-loader": "^0.5.5",
40
+ "jest": "23.6.0",
41
+ "mini-css-extract-plugin": "^0.4.3",
44
42
  "pug": "2.0.3",
45
43
  "pug-loader": "2.4.0",
46
- "rimraf": "2.6.3",
47
- "semistandard": "13.0.1",
48
- "standard-version": "5.0.2",
49
- "style-loader": "0.23.1",
50
- "typescript": "3.5.2",
51
- "webpack": "4.35.2",
52
- "webpack-recompilation-simulator": "3.0.0"
44
+ "rimraf": "^2.6.2",
45
+ "semistandard": "12.0.1",
46
+ "standard-version": "^4.4.0",
47
+ "style-loader": "^0.23.0",
48
+ "typescript": "^2.9.2",
49
+ "webpack": "^4.20.2",
50
+ "webpack-recompilation-simulator": "^3.0.0"
53
51
  },
54
52
  "dependencies": {
55
- "html-minifier-terser": "^5.0.1",
56
- "loader-utils": "^1.2.3",
57
- "lodash": "^4.17.15",
53
+ "html-minifier": "^3.5.20",
54
+ "loader-utils": "^1.1.0",
55
+ "lodash": "^4.17.11",
58
56
  "pretty-error": "^2.1.1",
59
- "tapable": "^1.1.3",
57
+ "tapable": "^1.1.0",
60
58
  "util.promisify": "1.0.0"
61
59
  },
62
60
  "peerDependencies": {
package/typings.d.ts CHANGED
@@ -1,246 +1,139 @@
1
- import { AsyncSeriesWaterfallHook } from "tapable";
2
- import { Compiler } from 'webpack';
3
- import { Options as HtmlMinifierOptions } from "html-minifier";
4
1
 
5
- export = HtmlWebpackPlugin;
6
-
7
- declare class HtmlWebpackPlugin {
8
- constructor(options?: HtmlWebpackPlugin.Options);
9
-
10
- apply(compiler: Compiler): void;
11
- }
12
-
13
- declare namespace HtmlWebpackPlugin {
14
- type MinifyOptions = HtmlMinifierOptions;
15
-
16
- interface Options extends Partial<ProcessedOptions> {}
17
-
18
- /**
19
- * The plugin options after adding default values
20
- */
21
- interface ProcessedOptions {
2
+ /**
3
+ * The plugin options
4
+ */
5
+ interface HtmlWebpackPluginOptions {
22
6
  /**
23
- * Emit the file only if it was changed.
24
- * Default: `true`.
25
- */
26
- cache: boolean;
27
- /**
28
- * List all entries which should be injected
7
+ * The title to use for the generated HTML document
29
8
  */
30
- chunks: "all" | string[];
9
+ title: string,
31
10
  /**
32
- * Allows to control how chunks should be sorted before they are included to the html.
33
- * Default: `'auto'`.
11
+ * The `webpack` require path to the template.
12
+ * @see https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md
34
13
  */
35
- chunksSortMode:
36
- | "auto"
37
- | "manual"
38
- | (((entryNameA: string, entryNameB: string) => number));
14
+ template: string,
39
15
  /**
40
- * List all entries which should not be injeccted
16
+ * Allow to use a html string instead of reading from a file
41
17
  */
42
- excludeChunks: string[];
18
+ templateContent:
19
+ false // Use the template option instead to load a file
20
+ | string
21
+ | Promise<string>,
43
22
  /**
44
- * Path to the favicon icon
23
+ * Allows to overwrite the parameters used in the template
45
24
  */
46
- favicon: false | string;
25
+ templateParameters:
26
+ false // Pass an empty object to the template function
27
+ | ((compilation: any, assets, assetTags: { headTags: Array<HtmlTagObject>, bodyTags: Array<HtmlTagObject> }, options: HtmlWebpackPluginOptions) => {[option: string]: any})
28
+ | ((compilation: any, assets, assetTags: { headTags: Array<HtmlTagObject>, bodyTags: Array<HtmlTagObject> }, options: HtmlWebpackPluginOptions) => Promise<{[option: string]: any}>)
29
+ | {[option: string]: any}
47
30
  /**
48
31
  * The file to write the HTML to.
49
32
  * Defaults to `index.html`.
50
33
  * Supports subdirectories eg: `assets/admin.html`
51
34
  */
52
- filename: string;
35
+ filename: string,
53
36
  /**
54
37
  * If `true` then append a unique `webpack` compilation hash to all included scripts and CSS files.
55
38
  * This is useful for cache busting
56
39
  */
57
- hash: boolean;
40
+ hash: boolean,
58
41
  /**
59
42
  * Inject all assets into the given `template` or `templateContent`.
60
43
  */
61
- inject:
62
- | false // Don't inject scripts
63
- | true // Inject scripts into body
64
- | "body" // Inject scripts into body
65
- | "head" // Inject scripts into head
44
+ inject: false // Don't inject scripts
45
+ | true // Inject scripts into body
46
+ | 'body' // Inject scripts into body
47
+ | 'head' // Inject scripts into head
66
48
  /**
67
- * Set up script loading
68
- * blocking will result in <script src="..."></script>
69
- * defer will result in <script defer src="..."></script>
70
- *
71
- * The default behaviour is blocking
72
- */
73
- scriptLoading:
74
- | "blocking"
75
- | "defer"
76
- /**
77
- * Inject meta tags
49
+ * Path to the favicon icon
78
50
  */
79
- meta:
80
- | false // Disable injection
81
- | {
82
- [name: string]:
83
- | string
84
- | false // name content pair e.g. {viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'}`
85
- | { [attributeName: string]: string | boolean }; // custom properties e.g. { name:"viewport" content:"width=500, initial-scale=1" }
86
- };
51
+ favicon: false | string,
87
52
  /**
88
- * HTML Minification options accepts the following valeus:
89
- * - Set to `false` to disable minifcation
90
- * - Set to `'auto'` to enable minifcation only for production mode
91
- * - Set to custom minification according to
53
+ * HTML Minification options
92
54
  * @https://github.com/kangax/html-minifier#options-quick-reference
93
55
  */
94
- minify: 'auto' | boolean | MinifyOptions;
56
+ minify?: boolean | {},
57
+ cache: boolean,
95
58
  /**
96
59
  * Render errors into the HTML page
97
60
  */
98
- showErrors: boolean;
61
+ showErrors: boolean,
99
62
  /**
100
- * The `webpack` require path to the template.
101
- * @see https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md
63
+ * List all entries which should be injected
102
64
  */
103
- template: string;
65
+ chunks: 'all' | string[],
104
66
  /**
105
- * Allow to use a html string instead of reading from a file
106
- */
107
- templateContent:
108
- | false // Use the template option instead to load a file
109
- | string
110
- | Promise<string>;
111
- /**
112
- * Allows to overwrite the parameters used in the template
67
+ * List all entries which should not be injeccted
113
68
  */
114
- templateParameters:
115
- | false // Pass an empty object to the template function
116
- | ((
117
- compilation: any,
118
- assets: {
119
- publicPath: string;
120
- js: Array<string>;
121
- css: Array<string>;
122
- manifest?: string;
123
- favicon?: string;
124
- },
125
- assetTags: {
126
- headTags: HtmlTagObject[];
127
- bodyTags: HtmlTagObject[];
128
- },
129
- options: ProcessedOptions
130
- ) => { [option: string]: any } | Promise<{ [option: string]: any }>)
131
- | { [option: string]: any };
69
+ excludeChunks: string[],
70
+ chunksSortMode: 'auto' | 'manual' | (((entryNameA: string, entryNameB: string) => number)),
132
71
  /**
133
- * The title to use for the generated HTML document
72
+ * Inject meta tags
134
73
  */
135
- title: string;
74
+ meta: false // Disable injection
75
+ | {
76
+ [name: string]: string|false // name content pair e.g. {viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'}`
77
+ | {[attributeName: string]: string|boolean} // custom properties e.g. { name:"viewport" content:"width=500, initial-scale=1" }
78
+ },
136
79
  /**
137
80
  * Enforce self closing tags e.g. <link />
138
81
  */
139
- xhtml: boolean;
82
+ xhtml: boolean
83
+
140
84
  /**
141
85
  * In addition to the options actually used by this plugin, you can use this hash to pass arbitrary data through
142
86
  * to your template.
143
87
  */
144
88
  [option: string]: any;
145
- }
89
+ }
146
90
 
91
+ /**
92
+ * A tag element according to the htmlWebpackPlugin object notation
93
+ */
94
+ interface HtmlTagObject {
147
95
  /**
148
- * The values which are available during template execution
149
- *
150
- * Please keep in mind that the `templateParameter` options allows to change them
96
+ * Attributes of the html tag
97
+ * E.g. `{'disabled': true, 'value': 'demo'}`
151
98
  */
152
- interface TemplateParameter {
153
- compilation: any;
154
- htmlWebpackPlugin: {
155
- tags: {
156
- headTags: HtmlTagObject[];
157
- bodyTags: HtmlTagObject[];
158
- };
159
- files: {
160
- publicPath: string;
161
- js: Array<string>;
162
- css: Array<string>;
163
- manifest?: string;
164
- favicon?: string;
165
- };
166
- options: Options;
167
- };
168
- webpackConfig: any;
169
- }
170
-
171
- interface Hooks {
172
- alterAssetTags: AsyncSeriesWaterfallHook<{
173
- assetTags: {
174
- scripts: HtmlTagObject[];
175
- styles: HtmlTagObject[];
176
- meta: HtmlTagObject[];
177
- };
178
- outputName: string;
179
- plugin: HtmlWebpackPlugin;
180
- }>;
181
-
182
- alterAssetTagGroups: AsyncSeriesWaterfallHook<{
183
- headTags: HtmlTagObject[];
184
- bodyTags: HtmlTagObject[];
185
- outputName: string;
186
- plugin: HtmlWebpackPlugin;
187
- }>;
188
-
189
- afterTemplateExecution: AsyncSeriesWaterfallHook<{
190
- html: string;
191
- headTags: HtmlTagObject[];
192
- bodyTags: HtmlTagObject[];
193
- outputName: string;
194
- plugin: HtmlWebpackPlugin;
195
- }>;
196
-
197
- beforeAssetTagGeneration: AsyncSeriesWaterfallHook<{
198
- assets: {
199
- publicPath: string;
200
- js: Array<string>;
201
- css: Array<string>;
202
- favicon?: string;
203
- manifest?: string;
204
- };
205
- outputName: string;
206
- plugin: HtmlWebpackPlugin;
207
- }>;
208
-
209
- beforeEmit: AsyncSeriesWaterfallHook<{
210
- html: string;
211
- outputName: string;
212
- plugin: HtmlWebpackPlugin;
213
- }>;
214
-
215
- afterEmit: AsyncSeriesWaterfallHook<{
216
- outputName: string;
217
- plugin: HtmlWebpackPlugin;
218
- }>;
219
- }
220
-
99
+ attributes: {
100
+ [attributeName: string]: string|boolean
101
+ },
221
102
  /**
222
- * A tag element according to the htmlWebpackPlugin object notation
103
+ * Wether this html must not contain innerHTML
104
+ * @see https://www.w3.org/TR/html5/syntax.html#void-elements
223
105
  */
224
- interface HtmlTagObject {
225
- /**
226
- * Attributes of the html tag
227
- * E.g. `{'disabled': true, 'value': 'demo'}`
228
- */
229
- attributes: {
230
- [attributeName: string]: string | boolean;
231
- };
232
- /**
233
- * The tag name e.g. `'div'`
234
- */
235
- tagName: string;
236
- /**
237
- * The inner HTML
238
- */
239
- innerHTML?: string;
240
- /**
241
- * Whether this html must not contain innerHTML
242
- * @see https://www.w3.org/TR/html5/syntax.html#void-elements
243
- */
244
- voidTag: boolean;
106
+ voidTag: boolean,
107
+ /**
108
+ * The tag name e.g. `'div'`
109
+ */
110
+ tagName: string,
111
+ /**
112
+ * Inner HTML The
113
+ */
114
+ innerHTML?: string
115
+ }
116
+
117
+ /**
118
+ * The values which are available during template execution
119
+ *
120
+ * Please keep in mind that the `templateParameter` options allows to change them
121
+ */
122
+ interface HtmlWebpackPluginTemplateParameter {
123
+ compilation: any,
124
+ webpackConfig: any
125
+ htmlWebpackPlugin: {
126
+ tags: {
127
+ headTags: HtmlTagObject[],
128
+ bodyTags: HtmlTagObject[]
129
+ },
130
+ files: {
131
+ publicPath: string,
132
+ js: Array<string>,
133
+ css: Array<string>,
134
+ manifest?: string,
135
+ favicon?: string
136
+ },
137
+ options: HtmlWebpackPluginOptions
245
138
  }
246
139
  }