html-webpack-plugin 5.5.1 → 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 +2 -5
- package/index.js +61 -8
- package/lib/child-compiler.js +1 -1
- package/lib/loader.js +3 -3
- package/package.json +3 -3
- package/typings.d.ts +2 -0
package/README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
[![npm][npm]][npm-url]
|
|
2
2
|
[![node][node]][node-url]
|
|
3
3
|

|
|
4
|
-
[![deps][deps]][deps-url]
|
|
5
4
|
[![tests][tests]][tests-url]
|
|
6
5
|
[](#backers)
|
|
7
6
|
[](#sponsors)
|
|
8
7
|
|
|
9
8
|
<div align="center">
|
|
10
|
-
<img width="200" height="200" src="https://
|
|
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 <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
|
-
|
|
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
|
-
|
|
136
|
-
|
|
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
|
-
|
|
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.
|
|
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/lib/child-compiler.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/** @typedef {import("webpack/lib/Compiler.js")} WebpackCompiler */
|
|
4
4
|
/** @typedef {import("webpack/lib/Chunk.js")} WebpackChunk */
|
|
5
5
|
'use strict';
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* @file
|
|
8
9
|
* This file uses webpack to compile a template with a child compiler.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
* [TEMPLATE] -> [JAVASCRIPT]
|
|
11
12
|
*
|
|
12
13
|
*/
|
|
13
|
-
'use strict';
|
|
14
14
|
|
|
15
15
|
let instanceId = 0;
|
|
16
16
|
/**
|
package/lib/loader.js
CHANGED
|
@@ -23,16 +23,16 @@ module.exports = function (source) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// Skip .js files (unless it's explicitly enforced)
|
|
26
|
-
if (/\.js$/.test(this.resourcePath) && !force) {
|
|
26
|
+
if (/\.(c|m)?js$/.test(this.resourcePath) && !force) {
|
|
27
27
|
return source;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
// The following part renders the template with lodash as a minimalistic loader
|
|
31
31
|
//
|
|
32
32
|
const template = _.template(source, { interpolate: /<%=([\s\S]+?)%>/g, variable: 'data', ...options });
|
|
33
|
-
// Use
|
|
33
|
+
// Use `eval("require")("lodash")` to enforce using the native nodejs require
|
|
34
34
|
// during template execution
|
|
35
|
-
return 'var _ =
|
|
35
|
+
return 'var _ = eval("require")(' + JSON.stringify(require.resolve('lodash')) + ');' +
|
|
36
36
|
'module.exports = function (templateParams) { with(templateParams) {' +
|
|
37
37
|
// Execute the lodash template
|
|
38
38
|
'return (' + template.source + ')();' +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-webpack-plugin",
|
|
3
|
-
"version": "5.5.
|
|
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": "
|
|
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",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"standard-version": "^9.3.0",
|
|
45
45
|
"style-loader": "2.0.0",
|
|
46
46
|
"typescript": "4.9.4",
|
|
47
|
-
"webpack": "^5.
|
|
47
|
+
"webpack": "^5.86.0",
|
|
48
48
|
"webpack-cli": "4.5.0",
|
|
49
49
|
"webpack-recompilation-simulator": "3.2.0"
|
|
50
50
|
},
|