html-webpack-plugin 5.5.2 → 5.5.3

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
@@ -1,13 +1,12 @@
1
1
  [![npm][npm]][npm-url]
2
2
  [![node][node]][node-url]
3
3
  ![npm](https://img.shields.io/npm/dw/html-webpack-plugin.svg)
4
- [![deps][deps]][deps-url]
5
4
  [![tests][tests]][tests-url]
6
5
  [![Backers on Open Collective](https://opencollective.com/html-webpack-plugin/backers/badge.svg)](#backers)
7
6
  [![Sponsors on Open Collective](https://opencollective.com/html-webpack-plugin/sponsors/badge.svg)](#sponsors)
8
7
 
9
8
  <div align="center">
10
- <img width="200" height="200" src="https://worldvectorlogo.com/logos/html5.svg">
9
+ <img width="200" height="200" src="https://www.w3.org/html/logo/downloads/HTML5_Badge.svg">
11
10
  <a href="https://github.com/webpack/webpack">
12
11
  <img width="200" height="200"
13
12
  src="https://webpack.js.org/assets/icon-square-big.svg">
@@ -90,6 +89,7 @@ The `html-webpack-plugin` provides [hooks](https://github.com/jantimon/html-webp
90
89
  * [html-webpack-skip-assets-plugin](https://github.com/swimmadude66/html-webpack-skip-assets-plugin) Skip adding certain output files to the html file. Built as a drop-in replacement for [html-webpack-exclude-assets-plugin](https://www.npmjs.com/package/html-webpack-exclude-assets-plugin) and works with newer [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin) versions
91
90
  * [html-webpack-inject-preload](https://github.com/principalstudio/html-webpack-inject-preload) allows to add preload links &lt;link rel='preload'> anywhere you want.
92
91
  * [inject-body-webpack-plugin](https://github.com/Jaid/inject-body-webpack-plugin) is a simple method of injecting a custom HTML string into the body.
92
+ * [html-webpack-plugin-django](https://github.com/TommasoAmici/html-webpack-plugin-django) a Webpack plugin to inject Django static tags.
93
93
 
94
94
 
95
95
  <h2 align="center">Usage</h2>
@@ -661,8 +661,5 @@ This project uses the [semistandard code style](https://github.com/Flet/semistan
661
661
  [node]: https://img.shields.io/node/v/html-webpack-plugin.svg
662
662
  [node-url]: https://nodejs.org
663
663
 
664
- [deps]: https://david-dm.org/jantimon/html-webpack-plugin.svg
665
- [deps-url]: https://david-dm.org/jantimon/html-webpack-plugin
666
-
667
664
  [tests]: https://github.com/jantimon/html-webpack-plugin/workflows/CI/badge.svg
668
665
  [tests-url]: https://github.com/jantimon/html-webpack-plugin/actions?query=workflow%3ACI
package/index.js CHANGED
@@ -76,7 +76,8 @@ class HtmlWebpackPlugin {
76
76
  // Default metaOptions if no template is provided
77
77
  if (!userOptions.template && options.templateContent === false && options.meta) {
78
78
  const defaultMeta = {
79
- // From https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag
79
+ // TODO remove in the next major release
80
+ // From https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag
80
81
  viewport: 'width=device-width, initial-scale=1'
81
82
  };
82
83
  options.meta = Object.assign({}, options.meta, defaultMeta, userOptions.meta);
@@ -132,8 +133,56 @@ class HtmlWebpackPlugin {
132
133
  HTML_WEBPACK_PLUGIN: true,
133
134
  require: require,
134
135
  htmlWebpackPluginPublicPath: publicPath,
135
- URL: require('url').URL,
136
- __filename: templateWithoutLoaders
136
+ __filename: templateWithoutLoaders,
137
+ __dirname: path.dirname(templateWithoutLoaders),
138
+ AbortController: global.AbortController,
139
+ AbortSignal: global.AbortSignal,
140
+ Blob: global.Blob,
141
+ Buffer: global.Buffer,
142
+ ByteLengthQueuingStrategy: global.ByteLengthQueuingStrategy,
143
+ BroadcastChannel: global.BroadcastChannel,
144
+ CompressionStream: global.CompressionStream,
145
+ CountQueuingStrategy: global.CountQueuingStrategy,
146
+ Crypto: global.Crypto,
147
+ CryptoKey: global.CryptoKey,
148
+ CustomEvent: global.CustomEvent,
149
+ DecompressionStream: global.DecompressionStream,
150
+ Event: global.Event,
151
+ EventTarget: global.EventTarget,
152
+ File: global.File,
153
+ FormData: global.FormData,
154
+ Headers: global.Headers,
155
+ MessageChannel: global.MessageChannel,
156
+ MessageEvent: global.MessageEvent,
157
+ MessagePort: global.MessagePort,
158
+ PerformanceEntry: global.PerformanceEntry,
159
+ PerformanceMark: global.PerformanceMark,
160
+ PerformanceMeasure: global.PerformanceMeasure,
161
+ PerformanceObserver: global.PerformanceObserver,
162
+ PerformanceObserverEntryList: global.PerformanceObserverEntryList,
163
+ PerformanceResourceTiming: global.PerformanceResourceTiming,
164
+ ReadableByteStreamController: global.ReadableByteStreamController,
165
+ ReadableStream: global.ReadableStream,
166
+ ReadableStreamBYOBReader: global.ReadableStreamBYOBReader,
167
+ ReadableStreamBYOBRequest: global.ReadableStreamBYOBRequest,
168
+ ReadableStreamDefaultController: global.ReadableStreamDefaultController,
169
+ ReadableStreamDefaultReader: global.ReadableStreamDefaultReader,
170
+ Response: global.Response,
171
+ Request: global.Request,
172
+ SubtleCrypto: global.SubtleCrypto,
173
+ DOMException: global.DOMException,
174
+ TextDecoder: global.TextDecoder,
175
+ TextDecoderStream: global.TextDecoderStream,
176
+ TextEncoder: global.TextEncoder,
177
+ TextEncoderStream: global.TextEncoderStream,
178
+ TransformStream: global.TransformStream,
179
+ TransformStreamDefaultController: global.TransformStreamDefaultController,
180
+ URL: global.URL,
181
+ URLSearchParams: global.URLSearchParams,
182
+ WebAssembly: global.WebAssembly,
183
+ WritableStream: global.WritableStream,
184
+ WritableStreamDefaultController: global.WritableStreamDefaultController,
185
+ WritableStreamDefaultWriter: global.WritableStreamDefaultWriter
137
186
  });
138
187
  const vmScript = new vm.Script(source, { filename: templateWithoutLoaders });
139
188
  // Evaluate code and cast to string
@@ -664,10 +713,7 @@ function hookIntoCompiler (compiler, options, plugin) {
664
713
  const entryPointUnfilteredFiles = compilation.entrypoints.get(entryName).getFiles();
665
714
 
666
715
  const entryPointFiles = entryPointUnfilteredFiles.filter((chunkFile) => {
667
- // compilation.getAsset was introduced in webpack 4.4.0
668
- // once the support pre webpack 4.4.0 is dropped please
669
- // remove the following guard:
670
- const asset = compilation.getAsset && compilation.getAsset(chunkFile);
716
+ const asset = compilation.getAsset(chunkFile);
671
717
  if (!asset) {
672
718
  return true;
673
719
  }
@@ -921,8 +967,15 @@ function hookIntoCompiler (compiler, options, plugin) {
921
967
  const htmlRegExp = /(<html[^>]*>)/i;
922
968
  const headRegExp = /(<\/head\s*>)/i;
923
969
  const bodyRegExp = /(<\/body\s*>)/i;
970
+ const metaViewportRegExp = /<meta[^>]+name=["']viewport["'][^>]*>/i;
924
971
  const body = assetTags.bodyTags.map((assetTagObject) => htmlTagObjectToString(assetTagObject, options.xhtml));
925
- const head = assetTags.headTags.map((assetTagObject) => htmlTagObjectToString(assetTagObject, options.xhtml));
972
+ const head = assetTags.headTags.filter((item) => {
973
+ if (item.tagName === 'meta' && item.attributes && item.attributes.name === 'viewport' && metaViewportRegExp.test(html)) {
974
+ return false;
975
+ }
976
+
977
+ return true;
978
+ }).map((assetTagObject) => htmlTagObjectToString(assetTagObject, options.xhtml));
926
979
 
927
980
  if (body.length) {
928
981
  if (bodyRegExp.test(html)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-webpack-plugin",
3
- "version": "5.5.2",
3
+ "version": "5.5.3",
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)",
@@ -28,7 +28,7 @@
28
28
  ]
29
29
  },
30
30
  "devDependencies": {
31
- "@types/node": "11.13.9",
31
+ "@types/node": "^20.2.5",
32
32
  "commitizen": "^4.2.4",
33
33
  "css-loader": "5.0.1",
34
34
  "cz-conventional-changelog": "2.1.0",
package/typings.d.ts CHANGED
@@ -52,6 +52,8 @@ declare namespace HtmlWebpackPlugin {
52
52
  */
53
53
  chunksSortMode?:
54
54
  | "auto"
55
+ // `none` is deprecated and an alias for `auto` now.
56
+ | "none"
55
57
  | "manual"
56
58
  | ((entryNameA: string, entryNameB: string) => number);
57
59
  /**