html-webpack-plugin 5.6.0 → 5.6.1
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 +147 -146
- package/index.js +785 -401
- package/lib/cached-child-compiler.js +172 -126
- package/lib/child-compiler.js +90 -53
- package/lib/chunksorter.js +7 -3
- package/lib/errors.js +10 -8
- package/lib/html-tags.js +41 -13
- package/lib/loader.js +26 -11
- package/package.json +28 -19
- package/typings.d.ts +8 -7
- package/lib/hooks.js +0 -108
package/lib/child-compiler.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
2
|
+
"use strict";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @file
|
|
@@ -22,7 +22,7 @@ class HtmlWebpackChildCompiler {
|
|
|
22
22
|
*
|
|
23
23
|
* @param {string[]} templates
|
|
24
24
|
*/
|
|
25
|
-
constructor
|
|
25
|
+
constructor(templates) {
|
|
26
26
|
/**
|
|
27
27
|
* @type {string[]} templateIds
|
|
28
28
|
* The template array will allow us to keep track which input generated which output
|
|
@@ -38,7 +38,11 @@ class HtmlWebpackChildCompiler {
|
|
|
38
38
|
* All file dependencies of the child compiler
|
|
39
39
|
* @type {{fileDependencies: string[], contextDependencies: string[], missingDependencies: string[]}}
|
|
40
40
|
*/
|
|
41
|
-
this.fileDependencies = {
|
|
41
|
+
this.fileDependencies = {
|
|
42
|
+
fileDependencies: [],
|
|
43
|
+
contextDependencies: [],
|
|
44
|
+
missingDependencies: [],
|
|
45
|
+
};
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
/**
|
|
@@ -46,7 +50,7 @@ class HtmlWebpackChildCompiler {
|
|
|
46
50
|
*
|
|
47
51
|
* @returns {boolean}
|
|
48
52
|
*/
|
|
49
|
-
isCompiling
|
|
53
|
+
isCompiling() {
|
|
50
54
|
return !this.didCompile() && this.compilationStartedTimestamp !== undefined;
|
|
51
55
|
}
|
|
52
56
|
|
|
@@ -55,7 +59,7 @@ class HtmlWebpackChildCompiler {
|
|
|
55
59
|
*
|
|
56
60
|
* @returns {boolean}
|
|
57
61
|
*/
|
|
58
|
-
didCompile
|
|
62
|
+
didCompile() {
|
|
59
63
|
return this.compilationEndedTimestamp !== undefined;
|
|
60
64
|
}
|
|
61
65
|
|
|
@@ -66,7 +70,7 @@ class HtmlWebpackChildCompiler {
|
|
|
66
70
|
* @param {import('webpack').Compilation} mainCompilation
|
|
67
71
|
* @returns {Promise<{[templatePath: string]: ChildCompilationTemplateResult}>}
|
|
68
72
|
*/
|
|
69
|
-
compileTemplates
|
|
73
|
+
compileTemplates(mainCompilation) {
|
|
70
74
|
const webpack = mainCompilation.compiler.webpack;
|
|
71
75
|
const Compilation = webpack.Compilation;
|
|
72
76
|
|
|
@@ -83,46 +87,62 @@ class HtmlWebpackChildCompiler {
|
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
const outputOptions = {
|
|
86
|
-
filename:
|
|
87
|
-
publicPath:
|
|
90
|
+
filename: "__child-[name]",
|
|
91
|
+
publicPath: "",
|
|
88
92
|
library: {
|
|
89
|
-
type:
|
|
90
|
-
name:
|
|
93
|
+
type: "var",
|
|
94
|
+
name: "HTML_WEBPACK_PLUGIN_RESULT",
|
|
91
95
|
},
|
|
92
|
-
scriptType: /** @type {'text/javascript'} */(
|
|
93
|
-
iife: true
|
|
96
|
+
scriptType: /** @type {'text/javascript'} */ ("text/javascript"),
|
|
97
|
+
iife: true,
|
|
94
98
|
};
|
|
95
|
-
const compilerName =
|
|
99
|
+
const compilerName = "HtmlWebpackCompiler";
|
|
96
100
|
// Create an additional child compiler which takes the template
|
|
97
101
|
// and turns it into an Node.JS html factory.
|
|
98
102
|
// This allows us to use loaders during the compilation
|
|
99
|
-
const childCompiler = mainCompilation.createChildCompiler(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
const childCompiler = mainCompilation.createChildCompiler(
|
|
104
|
+
compilerName,
|
|
105
|
+
outputOptions,
|
|
106
|
+
[
|
|
107
|
+
// Compile the template to nodejs javascript
|
|
108
|
+
new NodeTargetPlugin(),
|
|
109
|
+
new NodeTemplatePlugin(),
|
|
110
|
+
new LoaderTargetPlugin("node"),
|
|
111
|
+
new webpack.library.EnableLibraryPlugin("var"),
|
|
112
|
+
],
|
|
113
|
+
);
|
|
106
114
|
// The file path context which webpack uses to resolve all relative files to
|
|
107
115
|
childCompiler.context = mainCompilation.compiler.context;
|
|
108
116
|
|
|
109
117
|
// Generate output file names
|
|
110
|
-
const temporaryTemplateNames = this.templates.map(
|
|
118
|
+
const temporaryTemplateNames = this.templates.map(
|
|
119
|
+
(template, index) => `__child-HtmlWebpackPlugin_${index}-${template}`,
|
|
120
|
+
);
|
|
111
121
|
|
|
112
122
|
// Add all templates
|
|
113
123
|
this.templates.forEach((template, index) => {
|
|
114
|
-
new EntryPlugin(
|
|
115
|
-
|
|
124
|
+
new EntryPlugin(
|
|
125
|
+
childCompiler.context,
|
|
126
|
+
"data:text/javascript,__webpack_public_path__ = __webpack_base_uri__ = htmlWebpackPluginPublicPath;",
|
|
127
|
+
`HtmlWebpackPlugin_${index}-${template}`,
|
|
128
|
+
).apply(childCompiler);
|
|
129
|
+
new EntryPlugin(
|
|
130
|
+
childCompiler.context,
|
|
131
|
+
template,
|
|
132
|
+
`HtmlWebpackPlugin_${index}-${template}`,
|
|
133
|
+
).apply(childCompiler);
|
|
116
134
|
});
|
|
117
135
|
|
|
118
136
|
// The templates are compiled and executed by NodeJS - similar to server side rendering
|
|
119
137
|
// Unfortunately this causes issues as some loaders require an absolute URL to support ES Modules
|
|
120
138
|
// The following config enables relative URL support for the child compiler
|
|
121
139
|
childCompiler.options.module = { ...childCompiler.options.module };
|
|
122
|
-
childCompiler.options.module.parser = {
|
|
140
|
+
childCompiler.options.module.parser = {
|
|
141
|
+
...childCompiler.options.module.parser,
|
|
142
|
+
};
|
|
123
143
|
childCompiler.options.module.parser.javascript = {
|
|
124
144
|
...childCompiler.options.module.parser.javascript,
|
|
125
|
-
url:
|
|
145
|
+
url: "relative",
|
|
126
146
|
};
|
|
127
147
|
|
|
128
148
|
this.compilationStartedTimestamp = new Date().getTime();
|
|
@@ -131,23 +151,26 @@ class HtmlWebpackChildCompiler {
|
|
|
131
151
|
/** @type {Source[]} */
|
|
132
152
|
const extractedAssets = [];
|
|
133
153
|
|
|
134
|
-
childCompiler.hooks.thisCompilation.tap(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
154
|
+
childCompiler.hooks.thisCompilation.tap(
|
|
155
|
+
"HtmlWebpackPlugin",
|
|
156
|
+
(compilation) => {
|
|
157
|
+
compilation.hooks.processAssets.tap(
|
|
158
|
+
{
|
|
159
|
+
name: "HtmlWebpackPlugin",
|
|
160
|
+
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
|
|
161
|
+
},
|
|
162
|
+
(assets) => {
|
|
163
|
+
temporaryTemplateNames.forEach((temporaryTemplateName) => {
|
|
164
|
+
if (assets[temporaryTemplateName]) {
|
|
165
|
+
extractedAssets.push(assets[temporaryTemplateName]);
|
|
166
|
+
|
|
167
|
+
compilation.deleteAsset(temporaryTemplateName);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
},
|
|
171
|
+
);
|
|
172
|
+
},
|
|
173
|
+
);
|
|
151
174
|
|
|
152
175
|
childCompiler.runAsChild((err, entries, childCompilation) => {
|
|
153
176
|
// Extract templates
|
|
@@ -158,20 +181,34 @@ class HtmlWebpackChildCompiler {
|
|
|
158
181
|
|
|
159
182
|
// Extract file dependencies
|
|
160
183
|
if (entries && childCompilation) {
|
|
161
|
-
this.fileDependencies = {
|
|
184
|
+
this.fileDependencies = {
|
|
185
|
+
fileDependencies: Array.from(childCompilation.fileDependencies),
|
|
186
|
+
contextDependencies: Array.from(
|
|
187
|
+
childCompilation.contextDependencies,
|
|
188
|
+
),
|
|
189
|
+
missingDependencies: Array.from(
|
|
190
|
+
childCompilation.missingDependencies,
|
|
191
|
+
),
|
|
192
|
+
};
|
|
162
193
|
}
|
|
163
194
|
|
|
164
195
|
// Reject the promise if the childCompilation contains error
|
|
165
|
-
if (
|
|
166
|
-
|
|
196
|
+
if (
|
|
197
|
+
childCompilation &&
|
|
198
|
+
childCompilation.errors &&
|
|
199
|
+
childCompilation.errors.length
|
|
200
|
+
) {
|
|
201
|
+
const errorDetailsArray = [];
|
|
202
|
+
for (const error of childCompilation.errors) {
|
|
167
203
|
let message = error.message;
|
|
168
204
|
if (error.stack) {
|
|
169
|
-
message +=
|
|
205
|
+
message += "\n" + error.stack;
|
|
170
206
|
}
|
|
171
|
-
|
|
172
|
-
}
|
|
207
|
+
errorDetailsArray.push(message);
|
|
208
|
+
}
|
|
209
|
+
const errorDetails = errorDetailsArray.join("\n");
|
|
173
210
|
|
|
174
|
-
reject(new Error(
|
|
211
|
+
reject(new Error("Child compilation failed:\n" + errorDetails));
|
|
175
212
|
|
|
176
213
|
return;
|
|
177
214
|
}
|
|
@@ -183,7 +220,7 @@ class HtmlWebpackChildCompiler {
|
|
|
183
220
|
}
|
|
184
221
|
|
|
185
222
|
if (!childCompilation || !entries) {
|
|
186
|
-
reject(new Error(
|
|
223
|
+
reject(new Error("Empty child compilation"));
|
|
187
224
|
return;
|
|
188
225
|
}
|
|
189
226
|
|
|
@@ -206,9 +243,9 @@ class HtmlWebpackChildCompiler {
|
|
|
206
243
|
result[this.templates[entryIndex]] = {
|
|
207
244
|
// TODO, can we have Buffer here?
|
|
208
245
|
content: /** @type {string} */ (templateSource),
|
|
209
|
-
hash: childCompilation.hash ||
|
|
246
|
+
hash: childCompilation.hash || "XXXX",
|
|
210
247
|
entry: entries[entryIndex],
|
|
211
|
-
assets
|
|
248
|
+
assets,
|
|
212
249
|
};
|
|
213
250
|
});
|
|
214
251
|
|
|
@@ -223,5 +260,5 @@ class HtmlWebpackChildCompiler {
|
|
|
223
260
|
}
|
|
224
261
|
|
|
225
262
|
module.exports = {
|
|
226
|
-
HtmlWebpackChildCompiler
|
|
263
|
+
HtmlWebpackChildCompiler,
|
|
227
264
|
};
|
package/lib/chunksorter.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
2
|
+
"use strict";
|
|
3
3
|
|
|
4
4
|
/** @typedef {import("webpack").Compilation} Compilation */
|
|
5
5
|
|
|
@@ -14,7 +14,7 @@ module.exports = {};
|
|
|
14
14
|
* @param {Array<string>} chunks the chunks to sort
|
|
15
15
|
* @return {Array<string>} The sorted chunks
|
|
16
16
|
*/
|
|
17
|
-
module.exports.none = chunks => chunks;
|
|
17
|
+
module.exports.none = (chunks) => chunks;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Sort manually by the chunks
|
|
@@ -23,7 +23,11 @@ module.exports.none = chunks => chunks;
|
|
|
23
23
|
* @param {any} htmlWebpackPluginOptions the plugin options
|
|
24
24
|
* @return {string[]} The sorted chunks
|
|
25
25
|
*/
|
|
26
|
-
module.exports.manual = (
|
|
26
|
+
module.exports.manual = (
|
|
27
|
+
entryPointNames,
|
|
28
|
+
compilation,
|
|
29
|
+
htmlWebpackPluginOptions,
|
|
30
|
+
) => {
|
|
27
31
|
const chunks = htmlWebpackPluginOptions.chunks;
|
|
28
32
|
if (!Array.isArray(chunks)) {
|
|
29
33
|
return entryPointNames;
|
package/lib/errors.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
|
|
2
|
+
"use strict";
|
|
3
3
|
|
|
4
4
|
let prettyError;
|
|
5
5
|
|
|
6
|
-
function getPrettyError
|
|
6
|
+
function getPrettyError() {
|
|
7
7
|
if (!prettyError) {
|
|
8
8
|
// lazily require to improve startup time since pretty-error is rather heavy package
|
|
9
|
-
const PrettyError = require(
|
|
9
|
+
const PrettyError = require("pretty-error");
|
|
10
10
|
prettyError = new PrettyError();
|
|
11
11
|
prettyError.withoutColors();
|
|
12
|
-
prettyError.skipPackage(
|
|
12
|
+
prettyError.skipPackage("html-plugin-evaluation");
|
|
13
13
|
prettyError.skipNodeFiles();
|
|
14
14
|
prettyError.skip(function (traceLine) {
|
|
15
|
-
return traceLine.path ===
|
|
15
|
+
return traceLine.path === "html-plugin-evaluation";
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
return prettyError;
|
|
@@ -21,20 +21,22 @@ function getPrettyError () {
|
|
|
21
21
|
module.exports = function (err, context) {
|
|
22
22
|
return {
|
|
23
23
|
toHtml: function () {
|
|
24
|
-
return
|
|
24
|
+
return "Html Webpack Plugin:\n<pre>\n" + this.toString() + "</pre>";
|
|
25
25
|
},
|
|
26
26
|
toJsonHtml: function () {
|
|
27
27
|
return JSON.stringify(this.toHtml());
|
|
28
28
|
},
|
|
29
29
|
toString: function () {
|
|
30
30
|
try {
|
|
31
|
-
return getPrettyError()
|
|
31
|
+
return getPrettyError()
|
|
32
|
+
.render(err)
|
|
33
|
+
.replace(/webpack:\/\/\/\./g, context);
|
|
32
34
|
} catch (e) {
|
|
33
35
|
// This can sometimes fail. We don't know why, but returning the
|
|
34
36
|
// original error is better than returning the error thrown by
|
|
35
37
|
// pretty-error.
|
|
36
38
|
return err;
|
|
37
39
|
}
|
|
38
|
-
}
|
|
40
|
+
},
|
|
39
41
|
};
|
|
40
42
|
};
|
package/lib/html-tags.js
CHANGED
|
@@ -17,7 +17,23 @@
|
|
|
17
17
|
* All html tag elements which must not contain innerHTML
|
|
18
18
|
* @see https://www.w3.org/TR/html5/syntax.html#void-elements
|
|
19
19
|
*/
|
|
20
|
-
const voidTags = [
|
|
20
|
+
const voidTags = [
|
|
21
|
+
"area",
|
|
22
|
+
"base",
|
|
23
|
+
"br",
|
|
24
|
+
"col",
|
|
25
|
+
"embed",
|
|
26
|
+
"hr",
|
|
27
|
+
"img",
|
|
28
|
+
"input",
|
|
29
|
+
"keygen",
|
|
30
|
+
"link",
|
|
31
|
+
"meta",
|
|
32
|
+
"param",
|
|
33
|
+
"source",
|
|
34
|
+
"track",
|
|
35
|
+
"wbr",
|
|
36
|
+
];
|
|
21
37
|
|
|
22
38
|
/**
|
|
23
39
|
* Turn a tag definition into a html string
|
|
@@ -27,20 +43,32 @@ const voidTags = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'k
|
|
|
27
43
|
* @param xhtml {boolean}
|
|
28
44
|
* Whether the generated html should add closing slashes to be xhtml compliant
|
|
29
45
|
*/
|
|
30
|
-
function htmlTagObjectToString
|
|
46
|
+
function htmlTagObjectToString(tagDefinition, xhtml) {
|
|
31
47
|
const attributes = Object.keys(tagDefinition.attributes || {})
|
|
32
48
|
.filter(function (attributeName) {
|
|
33
|
-
return
|
|
49
|
+
return (
|
|
50
|
+
tagDefinition.attributes[attributeName] === "" ||
|
|
51
|
+
tagDefinition.attributes[attributeName]
|
|
52
|
+
);
|
|
34
53
|
})
|
|
35
54
|
.map(function (attributeName) {
|
|
36
55
|
if (tagDefinition.attributes[attributeName] === true) {
|
|
37
|
-
return xhtml
|
|
56
|
+
return xhtml
|
|
57
|
+
? attributeName + '="' + attributeName + '"'
|
|
58
|
+
: attributeName;
|
|
38
59
|
}
|
|
39
|
-
return
|
|
60
|
+
return (
|
|
61
|
+
attributeName + '="' + tagDefinition.attributes[attributeName] + '"'
|
|
62
|
+
);
|
|
40
63
|
});
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
|
|
64
|
+
return (
|
|
65
|
+
"<" +
|
|
66
|
+
[tagDefinition.tagName].concat(attributes).join(" ") +
|
|
67
|
+
(tagDefinition.voidTag && xhtml ? "/" : "") +
|
|
68
|
+
">" +
|
|
69
|
+
(tagDefinition.innerHTML || "") +
|
|
70
|
+
(tagDefinition.voidTag ? "" : "</" + tagDefinition.tagName + ">")
|
|
71
|
+
);
|
|
44
72
|
}
|
|
45
73
|
|
|
46
74
|
/**
|
|
@@ -59,13 +87,13 @@ function htmlTagObjectToString (tagDefinition, xhtml) {
|
|
|
59
87
|
*
|
|
60
88
|
* @returns {HtmlTagObject}
|
|
61
89
|
*/
|
|
62
|
-
function createHtmlTagObject
|
|
90
|
+
function createHtmlTagObject(tagName, attributes, innerHTML, meta) {
|
|
63
91
|
return {
|
|
64
92
|
tagName: tagName,
|
|
65
93
|
voidTag: voidTags.indexOf(tagName) !== -1,
|
|
66
94
|
attributes: attributes || {},
|
|
67
95
|
meta: meta || {},
|
|
68
|
-
innerHTML: innerHTML
|
|
96
|
+
innerHTML: innerHTML,
|
|
69
97
|
};
|
|
70
98
|
}
|
|
71
99
|
|
|
@@ -87,13 +115,13 @@ function createHtmlTagObject (tagName, attributes, innerHTML, meta) {
|
|
|
87
115
|
*
|
|
88
116
|
*/
|
|
89
117
|
class HtmlTagArray extends Array {
|
|
90
|
-
toString
|
|
91
|
-
return this.join(
|
|
118
|
+
toString() {
|
|
119
|
+
return this.join("");
|
|
92
120
|
}
|
|
93
121
|
}
|
|
94
122
|
|
|
95
123
|
module.exports = {
|
|
96
124
|
HtmlTagArray: HtmlTagArray,
|
|
97
125
|
createHtmlTagObject: createHtmlTagObject,
|
|
98
|
-
htmlTagObjectToString: htmlTagObjectToString
|
|
126
|
+
htmlTagObjectToString: htmlTagObjectToString,
|
|
99
127
|
};
|
package/lib/loader.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/* This loader renders the template with underscore if no other loader was found */
|
|
2
2
|
// @ts-nocheck
|
|
3
|
-
|
|
4
|
-
const
|
|
3
|
+
"use strict";
|
|
4
|
+
const _template = require("lodash/template");
|
|
5
5
|
|
|
6
6
|
module.exports = function (source) {
|
|
7
7
|
// Get templating options
|
|
8
8
|
const options = this.getOptions();
|
|
9
9
|
const force = options.force || false;
|
|
10
10
|
|
|
11
|
-
const allLoadersButThisOne = this.loaders.filter(
|
|
11
|
+
const allLoadersButThisOne = this.loaders.filter(
|
|
12
|
+
(loader) => loader.normal !== module.exports,
|
|
13
|
+
);
|
|
12
14
|
|
|
13
15
|
// This loader shouldn't kick in if there is any other loader (unless it's explicitly enforced)
|
|
14
16
|
if (allLoadersButThisOne.length > 0 && !force) {
|
|
@@ -16,8 +18,11 @@ module.exports = function (source) {
|
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
// Allow only one html-webpack-plugin loader to allow loader options in the webpack config
|
|
19
|
-
const htmlWebpackPluginLoaders = this.loaders.filter(
|
|
20
|
-
|
|
21
|
+
const htmlWebpackPluginLoaders = this.loaders.filter(
|
|
22
|
+
(loader) => loader.normal === module.exports,
|
|
23
|
+
);
|
|
24
|
+
const lastHtmlWebpackPluginLoader =
|
|
25
|
+
htmlWebpackPluginLoaders[htmlWebpackPluginLoaders.length - 1];
|
|
21
26
|
if (this.loaders[this.loaderIndex] !== lastHtmlWebpackPluginLoader) {
|
|
22
27
|
return source;
|
|
23
28
|
}
|
|
@@ -29,12 +34,22 @@ module.exports = function (source) {
|
|
|
29
34
|
|
|
30
35
|
// The following part renders the template with lodash as a minimalistic loader
|
|
31
36
|
//
|
|
32
|
-
const template =
|
|
37
|
+
const template = _template(source, {
|
|
38
|
+
interpolate: /<%=([\s\S]+?)%>/g,
|
|
39
|
+
variable: "data",
|
|
40
|
+
...options,
|
|
41
|
+
});
|
|
33
42
|
// Use `eval("require")("lodash")` to enforce using the native nodejs require
|
|
34
43
|
// during template execution
|
|
35
|
-
return
|
|
36
|
-
'
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
return (
|
|
45
|
+
'var _ = eval("require")(' +
|
|
46
|
+
JSON.stringify(require.resolve("lodash")) +
|
|
47
|
+
");" +
|
|
48
|
+
"module.exports = function (templateParams) { with(templateParams) {" +
|
|
49
|
+
// Execute the lodash template
|
|
50
|
+
"return (" +
|
|
51
|
+
template.source +
|
|
52
|
+
")();" +
|
|
53
|
+
"}}"
|
|
54
|
+
);
|
|
40
55
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-webpack-plugin",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.1",
|
|
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)",
|
|
@@ -13,38 +13,52 @@
|
|
|
13
13
|
"typings.d.ts"
|
|
14
14
|
],
|
|
15
15
|
"scripts": {
|
|
16
|
-
"pretest": "semistandard",
|
|
17
16
|
"posttest": "tsc",
|
|
18
|
-
"commit": "git-cz",
|
|
19
|
-
"build-examples": "node examples/build-examples.js",
|
|
20
|
-
"test": "jest --runInBand --verbose --coverage",
|
|
21
|
-
"test-watch": "jest --runInBand --watch",
|
|
22
17
|
"puml": "npx puml generate flow.puml -o flow.png",
|
|
18
|
+
"build-examples": "node examples/build-examples.js",
|
|
19
|
+
"commitlint": "commitlint --from=master",
|
|
20
|
+
"security": "npm audit --omit=dev",
|
|
21
|
+
"lint:prettier": "prettier --cache --list-different .",
|
|
22
|
+
"lint:js": "eslint --cache .",
|
|
23
|
+
"lint:spelling": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
|
|
24
|
+
"lint": "npm-run-all -l -p \"lint:**\"",
|
|
25
|
+
"fix:js": "npm run lint:js -- --fix",
|
|
26
|
+
"fix:prettier": "npm run lint:prettier -- --write",
|
|
27
|
+
"fix": "npm-run-all -l fix:js fix:prettier",
|
|
28
|
+
"test:only": "cross-env NODE_ENV=test jest",
|
|
29
|
+
"test:watch": "npm run test:only -- --watch",
|
|
30
|
+
"test:manual": "npm run build && webpack-dev-server test/manual/src/index.js --open --config test/manual/webpack.config.js",
|
|
31
|
+
"test:coverage": "npm run test:only -- --coverage",
|
|
32
|
+
"pretest": "npm run lint",
|
|
33
|
+
"test": "npm run test:coverage",
|
|
34
|
+
"prepare": "husky",
|
|
23
35
|
"release": "standard-version"
|
|
24
36
|
},
|
|
25
|
-
"semistandard": {
|
|
26
|
-
"ignore": [
|
|
27
|
-
"examples/*/dist/**/*.*"
|
|
28
|
-
]
|
|
29
|
-
},
|
|
30
37
|
"devDependencies": {
|
|
38
|
+
"@commitlint/cli": "^18.4.4",
|
|
39
|
+
"@commitlint/config-conventional": "^18.4.4",
|
|
31
40
|
"@types/node": "^20.2.5",
|
|
32
|
-
"
|
|
41
|
+
"cross-env": "^7.0.3",
|
|
42
|
+
"cspell": "^8.3.2",
|
|
33
43
|
"css-loader": "5.0.1",
|
|
34
44
|
"cz-conventional-changelog": "2.1.0",
|
|
35
45
|
"dir-compare": "^3.3.0",
|
|
46
|
+
"eslint": "^8.56.0",
|
|
36
47
|
"html-loader": "2.1.1",
|
|
48
|
+
"husky": "^9.0.10",
|
|
37
49
|
"jest": "^27.2.5",
|
|
50
|
+
"lint-staged": "^15.2.2",
|
|
38
51
|
"mini-css-extract-plugin": "^1.6.0",
|
|
52
|
+
"npm-run-all": "^4.1.5",
|
|
53
|
+
"prettier": "^3.2.5",
|
|
39
54
|
"pug": "3.0.2",
|
|
40
55
|
"pug-loader": "2.4.0",
|
|
41
56
|
"raw-loader": "4.0.2",
|
|
42
57
|
"rimraf": "2.6.3",
|
|
43
|
-
"semistandard": "^13.0.1",
|
|
44
58
|
"standard-version": "^9.3.0",
|
|
45
59
|
"style-loader": "2.0.0",
|
|
46
60
|
"typescript": "4.9.4",
|
|
47
|
-
"webpack": "^5.
|
|
61
|
+
"webpack": "^5.95.0",
|
|
48
62
|
"webpack-cli": "4.5.0",
|
|
49
63
|
"webpack-recompilation-simulator": "3.2.0"
|
|
50
64
|
},
|
|
@@ -79,11 +93,6 @@
|
|
|
79
93
|
"engines": {
|
|
80
94
|
"node": ">=10.13.0"
|
|
81
95
|
},
|
|
82
|
-
"config": {
|
|
83
|
-
"commitizen": {
|
|
84
|
-
"path": "./node_modules/cz-conventional-changelog"
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
96
|
"jest": {
|
|
88
97
|
"watchPathIgnorePatterns": [
|
|
89
98
|
"<rootDir>/dist"
|
package/typings.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ declare class HtmlWebpackPlugin {
|
|
|
20
20
|
apply(compiler: Compiler): void;
|
|
21
21
|
|
|
22
22
|
static getHooks(compilation: Compilation): HtmlWebpackPlugin.Hooks;
|
|
23
|
+
static getCompilationHooks(compilation: Compilation): HtmlWebpackPlugin.Hooks;
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Static helper to create a tag object to be get injected into the dom
|
|
@@ -27,7 +28,7 @@ declare class HtmlWebpackPlugin {
|
|
|
27
28
|
static createHtmlTagObject(
|
|
28
29
|
tagName: string,
|
|
29
30
|
attributes?: { [attributeName: string]: string | boolean },
|
|
30
|
-
innerHTML?: string
|
|
31
|
+
innerHTML?: string,
|
|
31
32
|
): HtmlWebpackPlugin.HtmlTagObject;
|
|
32
33
|
|
|
33
34
|
static readonly version: number;
|
|
@@ -112,8 +113,8 @@ declare namespace HtmlWebpackPlugin {
|
|
|
112
113
|
};
|
|
113
114
|
/**
|
|
114
115
|
* HTML Minification options accepts the following values:
|
|
115
|
-
* - Set to `false` to disable
|
|
116
|
-
* - Set to `'auto'` to enable
|
|
116
|
+
* - Set to `false` to disable minification
|
|
117
|
+
* - Set to `'auto'` to enable minification only for production mode
|
|
117
118
|
* - Set to custom minification according to
|
|
118
119
|
* {@link https://github.com/kangax/html-minifier#options-quick-reference}
|
|
119
120
|
*/
|
|
@@ -155,7 +156,7 @@ declare namespace HtmlWebpackPlugin {
|
|
|
155
156
|
headTags: HtmlTagObject[];
|
|
156
157
|
bodyTags: HtmlTagObject[];
|
|
157
158
|
},
|
|
158
|
-
options: ProcessedOptions
|
|
159
|
+
options: ProcessedOptions,
|
|
159
160
|
) => { [option: string]: any } | Promise<{ [option: string]: any }>)
|
|
160
161
|
| { [option: string]: any };
|
|
161
162
|
/**
|
|
@@ -211,7 +212,7 @@ declare namespace HtmlWebpackPlugin {
|
|
|
211
212
|
styles: HtmlTagObject[];
|
|
212
213
|
meta: HtmlTagObject[];
|
|
213
214
|
};
|
|
214
|
-
publicPath: string
|
|
215
|
+
publicPath: string;
|
|
215
216
|
outputName: string;
|
|
216
217
|
plugin: HtmlWebpackPlugin;
|
|
217
218
|
}>;
|
|
@@ -220,7 +221,7 @@ declare namespace HtmlWebpackPlugin {
|
|
|
220
221
|
headTags: HtmlTagObject[];
|
|
221
222
|
bodyTags: HtmlTagObject[];
|
|
222
223
|
outputName: string;
|
|
223
|
-
publicPath: string
|
|
224
|
+
publicPath: string;
|
|
224
225
|
plugin: HtmlWebpackPlugin;
|
|
225
226
|
}>;
|
|
226
227
|
|
|
@@ -285,7 +286,7 @@ declare namespace HtmlWebpackPlugin {
|
|
|
285
286
|
* E.g. `{'plugin': 'html-webpack-plugin'}`
|
|
286
287
|
*/
|
|
287
288
|
meta: {
|
|
288
|
-
plugin?: string
|
|
289
|
+
plugin?: string;
|
|
289
290
|
[metaAttributeName: string]: any;
|
|
290
291
|
};
|
|
291
292
|
}
|