1 |
|
2 | "use strict";
|
3 |
|
4 | const promisify = require("util").promisify;
|
5 |
|
6 | const vm = require("vm");
|
7 | const fs = require("fs");
|
8 | const _uniq = require("lodash/uniq");
|
9 | const path = require("path");
|
10 | const { CachedChildCompilation } = require("./lib/cached-child-compiler");
|
11 |
|
12 | const {
|
13 | createHtmlTagObject,
|
14 | htmlTagObjectToString,
|
15 | HtmlTagArray,
|
16 | } = require("./lib/html-tags");
|
17 | const prettyError = require("./lib/errors.js");
|
18 | const chunkSorter = require("./lib/chunksorter.js");
|
19 | const { AsyncSeriesWaterfallHook } = require("tapable");
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | const compilationHooksMap = new WeakMap();
|
37 |
|
38 | class HtmlWebpackPlugin {
|
39 |
|
40 |
|
41 | |
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 | |
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 | static getCompilationHooks(compilation) {
|
101 | let hooks = compilationHooksMap.get(compilation);
|
102 |
|
103 | if (!hooks) {
|
104 | hooks = {
|
105 | beforeAssetTagGeneration: new AsyncSeriesWaterfallHook(["pluginArgs"]),
|
106 | alterAssetTags: new AsyncSeriesWaterfallHook(["pluginArgs"]),
|
107 | alterAssetTagGroups: new AsyncSeriesWaterfallHook(["pluginArgs"]),
|
108 | afterTemplateExecution: new AsyncSeriesWaterfallHook(["pluginArgs"]),
|
109 | beforeEmit: new AsyncSeriesWaterfallHook(["pluginArgs"]),
|
110 | afterEmit: new AsyncSeriesWaterfallHook(["pluginArgs"]),
|
111 | };
|
112 | compilationHooksMap.set(compilation, hooks);
|
113 | }
|
114 |
|
115 | return hooks;
|
116 | }
|
117 |
|
118 | |
119 |
|
120 |
|
121 | constructor(options) {
|
122 |
|
123 |
|
124 | this.userOptions = options || {};
|
125 | this.version = HtmlWebpackPlugin.version;
|
126 |
|
127 |
|
128 |
|
129 | const defaultOptions = {
|
130 | template: "auto",
|
131 | templateContent: false,
|
132 | templateParameters: templateParametersGenerator,
|
133 | filename: "index.html",
|
134 | publicPath:
|
135 | this.userOptions.publicPath === undefined
|
136 | ? "auto"
|
137 | : this.userOptions.publicPath,
|
138 | hash: false,
|
139 | inject: this.userOptions.scriptLoading === "blocking" ? "body" : "head",
|
140 | scriptLoading: "defer",
|
141 | compile: true,
|
142 | favicon: false,
|
143 | minify: "auto",
|
144 | cache: true,
|
145 | showErrors: true,
|
146 | chunks: "all",
|
147 | excludeChunks: [],
|
148 | chunksSortMode: "auto",
|
149 | meta: {},
|
150 | base: false,
|
151 | title: "Webpack App",
|
152 | xhtml: false,
|
153 | };
|
154 |
|
155 |
|
156 | this.options = Object.assign(defaultOptions, this.userOptions);
|
157 | }
|
158 |
|
159 | |
160 |
|
161 |
|
162 |
|
163 |
|
164 | apply(compiler) {
|
165 | this.logger = compiler.getInfrastructureLogger("HtmlWebpackPlugin");
|
166 |
|
167 | const options = this.options;
|
168 |
|
169 | options.template = this.getTemplatePath(
|
170 | this.options.template,
|
171 | compiler.context,
|
172 | );
|
173 |
|
174 |
|
175 | if (
|
176 | options.scriptLoading !== "defer" &&
|
177 | options.scriptLoading !== "blocking" &&
|
178 | options.scriptLoading !== "module" &&
|
179 | options.scriptLoading !== "systemjs-module"
|
180 | ) {
|
181 |
|
182 | (this.logger).error(
|
183 | 'The "scriptLoading" option need to be set to "defer", "blocking" or "module" or "systemjs-module"',
|
184 | );
|
185 | }
|
186 |
|
187 | if (
|
188 | options.inject !== true &&
|
189 | options.inject !== false &&
|
190 | options.inject !== "head" &&
|
191 | options.inject !== "body"
|
192 | ) {
|
193 |
|
194 | (this.logger).error(
|
195 | 'The `inject` option needs to be set to true, false, "head" or "body',
|
196 | );
|
197 | }
|
198 |
|
199 | if (
|
200 | this.options.templateParameters !== false &&
|
201 | typeof this.options.templateParameters !== "function" &&
|
202 | typeof this.options.templateParameters !== "object"
|
203 | ) {
|
204 |
|
205 | (this.logger).error(
|
206 | "The `templateParameters` has to be either a function or an object or false",
|
207 | );
|
208 | }
|
209 |
|
210 |
|
211 | if (
|
212 | !this.userOptions.template &&
|
213 | options.templateContent === false &&
|
214 | options.meta
|
215 | ) {
|
216 | options.meta = Object.assign(
|
217 | {},
|
218 | options.meta,
|
219 | {
|
220 |
|
221 |
|
222 | viewport: "width=device-width, initial-scale=1",
|
223 | },
|
224 | this.userOptions.meta,
|
225 | );
|
226 | }
|
227 |
|
228 |
|
229 | const userOptionFilename =
|
230 | this.userOptions.filename || this.options.filename;
|
231 | const filenameFunction =
|
232 | typeof userOptionFilename === "function"
|
233 | ? userOptionFilename
|
234 | :
|
235 | (entryName) => userOptionFilename.replace(/\[name\]/g, entryName);
|
236 |
|
237 |
|
238 | const entryNames = Object.keys(compiler.options.entry);
|
239 | const outputFileNames = new Set(
|
240 | (entryNames.length ? entryNames : ["main"]).map(filenameFunction),
|
241 | );
|
242 |
|
243 |
|
244 | outputFileNames.forEach((outputFileName) => {
|
245 |
|
246 | const assetJson = { value: undefined };
|
247 | |
248 |
|
249 |
|
250 |
|
251 |
|
252 | const previousEmittedAssets = [];
|
253 |
|
254 |
|
255 | const childCompilerPlugin = new CachedChildCompilation(compiler);
|
256 |
|
257 | if (!this.options.templateContent) {
|
258 | childCompilerPlugin.addEntry(this.options.template);
|
259 | }
|
260 |
|
261 |
|
262 |
|
263 | let filename = outputFileName;
|
264 |
|
265 | if (path.resolve(filename) === path.normalize(filename)) {
|
266 | const outputPath =
|
267 | (
|
268 | compiler.options.output.path
|
269 | );
|
270 |
|
271 | filename = path.relative(outputPath, filename);
|
272 | }
|
273 |
|
274 | compiler.hooks.thisCompilation.tap(
|
275 | "HtmlWebpackPlugin",
|
276 | |
277 |
|
278 |
|
279 |
|
280 | (compilation) => {
|
281 | compilation.hooks.processAssets.tapAsync(
|
282 | {
|
283 | name: "HtmlWebpackPlugin",
|
284 | stage:
|
285 | |
286 |
|
287 |
|
288 | compiler.webpack.Compilation
|
289 | .PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE,
|
290 | },
|
291 | |
292 |
|
293 |
|
294 |
|
295 |
|
296 | (_, callback) => {
|
297 | this.generateHTML(
|
298 | compiler,
|
299 | compilation,
|
300 | filename,
|
301 | childCompilerPlugin,
|
302 | previousEmittedAssets,
|
303 | assetJson,
|
304 | callback,
|
305 | );
|
306 | },
|
307 | );
|
308 | },
|
309 | );
|
310 | });
|
311 | }
|
312 |
|
313 | |
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 | getTemplatePath(template, context) {
|
321 | if (template === "auto") {
|
322 | template = path.resolve(context, "src/index.ejs");
|
323 | if (!fs.existsSync(template)) {
|
324 | template = path.join(__dirname, "default_index.ejs");
|
325 | }
|
326 | }
|
327 |
|
328 |
|
329 | if (template.indexOf("!") === -1) {
|
330 | template =
|
331 | require.resolve("./lib/loader.js") +
|
332 | "!" +
|
333 | path.resolve(context, template);
|
334 | }
|
335 |
|
336 |
|
337 | return template.replace(
|
338 | /([!])([^/\\][^!?]+|[^/\\!?])($|\?[^!?\n]+$)/,
|
339 | (match, prefix, filepath, postfix) =>
|
340 | prefix + path.resolve(filepath) + postfix,
|
341 | );
|
342 | }
|
343 |
|
344 | |
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 | filterEntryChunks(chunks, includedChunks, excludedChunks) {
|
353 | return chunks.filter((chunkName) => {
|
354 |
|
355 | if (
|
356 | Array.isArray(includedChunks) &&
|
357 | includedChunks.indexOf(chunkName) === -1
|
358 | ) {
|
359 | return false;
|
360 | }
|
361 |
|
362 |
|
363 | if (
|
364 | Array.isArray(excludedChunks) &&
|
365 | excludedChunks.indexOf(chunkName) !== -1
|
366 | ) {
|
367 | return false;
|
368 | }
|
369 |
|
370 |
|
371 | return true;
|
372 | });
|
373 | }
|
374 |
|
375 | |
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 | sortEntryChunks(entryNames, sortMode, compilation) {
|
384 |
|
385 | if (typeof sortMode === "function") {
|
386 | return entryNames.sort(sortMode);
|
387 | }
|
388 |
|
389 | if (typeof chunkSorter[sortMode] !== "undefined") {
|
390 | return chunkSorter[sortMode](entryNames, compilation, this.options);
|
391 | }
|
392 | throw new Error('"' + sortMode + '" is not a valid chunk sort mode');
|
393 | }
|
394 |
|
395 | |
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 | urlencodePath(filePath) {
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 | const queryStringStart = filePath.indexOf("?");
|
424 | const urlPath =
|
425 | queryStringStart === -1 ? filePath : filePath.substr(0, queryStringStart);
|
426 | const queryString = filePath.substr(urlPath.length);
|
427 |
|
428 | const encodedUrlPath = urlPath.split("/").map(encodeURIComponent).join("/");
|
429 | return encodedUrlPath + queryString;
|
430 | }
|
431 |
|
432 | |
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 | appendHash(url, hash) {
|
441 | if (!url) {
|
442 | return url;
|
443 | }
|
444 |
|
445 | return url + (url.indexOf("?") === -1 ? "?" : "&") + hash;
|
446 | }
|
447 |
|
448 | |
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 | getPublicPath(compilation, filename, customPublicPath) {
|
459 | |
460 |
|
461 |
|
462 |
|
463 |
|
464 | const webpackPublicPath = compilation.getAssetPath(
|
465 | (
|
466 | compilation.outputOptions.publicPath
|
467 | ),
|
468 | { hash: compilation.hash },
|
469 | );
|
470 |
|
471 | const isPublicPathDefined = webpackPublicPath !== "auto";
|
472 |
|
473 | let publicPath =
|
474 |
|
475 | customPublicPath !== "auto"
|
476 | ? customPublicPath
|
477 | : isPublicPathDefined
|
478 | ?
|
479 | webpackPublicPath
|
480 | :
|
481 | path
|
482 | .relative(
|
483 | path.resolve(
|
484 | (compilation.options.output.path),
|
485 | path.dirname(filename),
|
486 | ),
|
487 | (compilation.options.output.path),
|
488 | )
|
489 | .split(path.sep)
|
490 | .join("/");
|
491 |
|
492 | if (publicPath.length && publicPath.substr(-1, 1) !== "/") {
|
493 | publicPath += "/";
|
494 | }
|
495 |
|
496 | return publicPath;
|
497 | }
|
498 |
|
499 | |
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 | getAssetsInformationByGroups(compilation, outputName, entryNames) {
|
509 |
|
510 | const publicPath = this.getPublicPath(
|
511 | compilation,
|
512 | outputName,
|
513 | this.options.publicPath,
|
514 | );
|
515 | |
516 |
|
517 |
|
518 | const assets = {
|
519 |
|
520 | publicPath,
|
521 |
|
522 | js: [],
|
523 |
|
524 | css: [],
|
525 |
|
526 | manifest: Object.keys(compilation.assets).find(
|
527 | (assetFile) => path.extname(assetFile) === ".appcache",
|
528 | ),
|
529 |
|
530 | favicon: undefined,
|
531 | };
|
532 |
|
533 |
|
534 | if (this.options.hash && assets.manifest) {
|
535 | assets.manifest = this.appendHash(
|
536 | assets.manifest,
|
537 | (compilation.hash),
|
538 | );
|
539 | }
|
540 |
|
541 |
|
542 | const entryPointPublicPathMap = {};
|
543 | const extensionRegexp = /\.(css|js|mjs)(\?|$)/;
|
544 |
|
545 | for (let i = 0; i < entryNames.length; i++) {
|
546 | const entryName = entryNames[i];
|
547 |
|
548 | const entryPointUnfilteredFiles = (
|
549 | compilation.entrypoints.get(entryName)
|
550 | ).getFiles();
|
551 | const entryPointFiles = entryPointUnfilteredFiles.filter((chunkFile) => {
|
552 | const asset = compilation.getAsset(chunkFile);
|
553 |
|
554 | if (!asset) {
|
555 | return true;
|
556 | }
|
557 |
|
558 |
|
559 | const assetMetaInformation = asset.info || {};
|
560 |
|
561 | return !(
|
562 | assetMetaInformation.hotModuleReplacement ||
|
563 | assetMetaInformation.development
|
564 | );
|
565 | });
|
566 |
|
567 |
|
568 |
|
569 | const entryPointPublicPaths = entryPointFiles.map((chunkFile) => {
|
570 | const entryPointPublicPath = publicPath + this.urlencodePath(chunkFile);
|
571 | return this.options.hash
|
572 | ? this.appendHash(
|
573 | entryPointPublicPath,
|
574 | (compilation.hash),
|
575 | )
|
576 | : entryPointPublicPath;
|
577 | });
|
578 |
|
579 | entryPointPublicPaths.forEach((entryPointPublicPath) => {
|
580 | const extMatch = extensionRegexp.exec(
|
581 | (entryPointPublicPath),
|
582 | );
|
583 |
|
584 |
|
585 | if (!extMatch) {
|
586 | return;
|
587 | }
|
588 |
|
589 |
|
590 |
|
591 | if (entryPointPublicPathMap[entryPointPublicPath]) {
|
592 | return;
|
593 | }
|
594 |
|
595 | entryPointPublicPathMap[entryPointPublicPath] = true;
|
596 |
|
597 |
|
598 | const ext = extMatch[1] === "mjs" ? "js" : extMatch[1];
|
599 |
|
600 | assets[ext].push(entryPointPublicPath);
|
601 | });
|
602 | }
|
603 |
|
604 | return assets;
|
605 | }
|
606 |
|
607 | |
608 |
|
609 |
|
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 | evaluateCompilationResult(source, publicPath, templateFilename) {
|
620 | if (!source) {
|
621 | return Promise.reject(
|
622 | new Error("The child compilation didn't provide a result"),
|
623 | );
|
624 | }
|
625 |
|
626 |
|
627 |
|
628 | if (source.indexOf("HTML_WEBPACK_PLUGIN_RESULT") >= 0) {
|
629 | source += ";\nHTML_WEBPACK_PLUGIN_RESULT";
|
630 | }
|
631 |
|
632 | const templateWithoutLoaders = templateFilename
|
633 | .replace(/^.+!/, "")
|
634 | .replace(/\?.+$/, "");
|
635 | const vmContext = vm.createContext({
|
636 | ...global,
|
637 | HTML_WEBPACK_PLUGIN: true,
|
638 | require: require,
|
639 | htmlWebpackPluginPublicPath: publicPath,
|
640 | __filename: templateWithoutLoaders,
|
641 | __dirname: path.dirname(templateWithoutLoaders),
|
642 | AbortController: global.AbortController,
|
643 | AbortSignal: global.AbortSignal,
|
644 | Blob: global.Blob,
|
645 | Buffer: global.Buffer,
|
646 | ByteLengthQueuingStrategy: global.ByteLengthQueuingStrategy,
|
647 | BroadcastChannel: global.BroadcastChannel,
|
648 | CompressionStream: global.CompressionStream,
|
649 | CountQueuingStrategy: global.CountQueuingStrategy,
|
650 | Crypto: global.Crypto,
|
651 | CryptoKey: global.CryptoKey,
|
652 | CustomEvent: global.CustomEvent,
|
653 | DecompressionStream: global.DecompressionStream,
|
654 | Event: global.Event,
|
655 | EventTarget: global.EventTarget,
|
656 | File: global.File,
|
657 | FormData: global.FormData,
|
658 | Headers: global.Headers,
|
659 | MessageChannel: global.MessageChannel,
|
660 | MessageEvent: global.MessageEvent,
|
661 | MessagePort: global.MessagePort,
|
662 | PerformanceEntry: global.PerformanceEntry,
|
663 | PerformanceMark: global.PerformanceMark,
|
664 | PerformanceMeasure: global.PerformanceMeasure,
|
665 | PerformanceObserver: global.PerformanceObserver,
|
666 | PerformanceObserverEntryList: global.PerformanceObserverEntryList,
|
667 | PerformanceResourceTiming: global.PerformanceResourceTiming,
|
668 | ReadableByteStreamController: global.ReadableByteStreamController,
|
669 | ReadableStream: global.ReadableStream,
|
670 | ReadableStreamBYOBReader: global.ReadableStreamBYOBReader,
|
671 | ReadableStreamBYOBRequest: global.ReadableStreamBYOBRequest,
|
672 | ReadableStreamDefaultController: global.ReadableStreamDefaultController,
|
673 | ReadableStreamDefaultReader: global.ReadableStreamDefaultReader,
|
674 | Response: global.Response,
|
675 | Request: global.Request,
|
676 | SubtleCrypto: global.SubtleCrypto,
|
677 | DOMException: global.DOMException,
|
678 | TextDecoder: global.TextDecoder,
|
679 | TextDecoderStream: global.TextDecoderStream,
|
680 | TextEncoder: global.TextEncoder,
|
681 | TextEncoderStream: global.TextEncoderStream,
|
682 | TransformStream: global.TransformStream,
|
683 | TransformStreamDefaultController: global.TransformStreamDefaultController,
|
684 | URL: global.URL,
|
685 | URLSearchParams: global.URLSearchParams,
|
686 | WebAssembly: global.WebAssembly,
|
687 | WritableStream: global.WritableStream,
|
688 | WritableStreamDefaultController: global.WritableStreamDefaultController,
|
689 | WritableStreamDefaultWriter: global.WritableStreamDefaultWriter,
|
690 | });
|
691 |
|
692 | const vmScript = new vm.Script(source, {
|
693 | filename: templateWithoutLoaders,
|
694 | });
|
695 |
|
696 |
|
697 | let newSource;
|
698 |
|
699 | try {
|
700 | newSource = vmScript.runInContext(vmContext);
|
701 | } catch (e) {
|
702 | return Promise.reject(e);
|
703 | }
|
704 |
|
705 | if (
|
706 | typeof newSource === "object" &&
|
707 | newSource.__esModule &&
|
708 | newSource.default !== undefined
|
709 | ) {
|
710 | newSource = newSource.default;
|
711 | }
|
712 |
|
713 | return typeof newSource === "string" || typeof newSource === "function"
|
714 | ? Promise.resolve(newSource)
|
715 | : Promise.reject(
|
716 | new Error(
|
717 | 'The loader "' + templateWithoutLoaders + "\" didn't return html.",
|
718 | ),
|
719 | );
|
720 | }
|
721 |
|
722 | |
723 |
|
724 |
|
725 |
|
726 |
|
727 |
|
728 |
|
729 | prepareAssetTagGroupForRendering(assetTagGroup) {
|
730 | const xhtml = this.options.xhtml;
|
731 | return HtmlTagArray.from(
|
732 | assetTagGroup.map((assetTag) => {
|
733 | const copiedAssetTag = Object.assign({}, assetTag);
|
734 | copiedAssetTag.toString = function () {
|
735 | return htmlTagObjectToString(this, xhtml);
|
736 | };
|
737 | return copiedAssetTag;
|
738 | }),
|
739 | );
|
740 | }
|
741 |
|
742 | |
743 |
|
744 |
|
745 |
|
746 |
|
747 |
|
748 |
|
749 |
|
750 |
|
751 |
|
752 |
|
753 |
|
754 | getTemplateParameters(compilation, assetsInformationByGroups, assetTags) {
|
755 | const templateParameters = this.options.templateParameters;
|
756 |
|
757 | if (templateParameters === false) {
|
758 | return Promise.resolve({});
|
759 | }
|
760 |
|
761 | if (
|
762 | typeof templateParameters !== "function" &&
|
763 | typeof templateParameters !== "object"
|
764 | ) {
|
765 | throw new Error(
|
766 | "templateParameters has to be either a function or an object",
|
767 | );
|
768 | }
|
769 |
|
770 | const templateParameterFunction =
|
771 | typeof templateParameters === "function"
|
772 | ?
|
773 | templateParameters
|
774 | :
|
775 | (compilation, assetsInformationByGroups, assetTags, options) =>
|
776 | Object.assign(
|
777 | {},
|
778 | templateParametersGenerator(
|
779 | compilation,
|
780 | assetsInformationByGroups,
|
781 | assetTags,
|
782 | options,
|
783 | ),
|
784 | templateParameters,
|
785 | );
|
786 | const preparedAssetTags = {
|
787 | headTags: this.prepareAssetTagGroupForRendering(assetTags.headTags),
|
788 | bodyTags: this.prepareAssetTagGroupForRendering(assetTags.bodyTags),
|
789 | };
|
790 | return Promise.resolve().then(() =>
|
791 | templateParameterFunction(
|
792 | compilation,
|
793 | assetsInformationByGroups,
|
794 | preparedAssetTags,
|
795 | this.options,
|
796 | ),
|
797 | );
|
798 | }
|
799 |
|
800 | |
801 |
|
802 |
|
803 |
|
804 |
|
805 |
|
806 |
|
807 |
|
808 |
|
809 |
|
810 |
|
811 |
|
812 |
|
813 | executeTemplate(
|
814 | templateFunction,
|
815 | assetsInformationByGroups,
|
816 | assetTags,
|
817 | compilation,
|
818 | ) {
|
819 |
|
820 | const templateParamsPromise = this.getTemplateParameters(
|
821 | compilation,
|
822 | assetsInformationByGroups,
|
823 | assetTags,
|
824 | );
|
825 |
|
826 | return templateParamsPromise.then((templateParams) => {
|
827 | try {
|
828 |
|
829 |
|
830 | return templateFunction(templateParams);
|
831 | } catch (e) {
|
832 |
|
833 | compilation.errors.push(new Error("Template execution failed: " + e));
|
834 | return Promise.reject(e);
|
835 | }
|
836 | });
|
837 | }
|
838 |
|
839 | |
840 |
|
841 |
|
842 |
|
843 |
|
844 |
|
845 |
|
846 |
|
847 |
|
848 |
|
849 | postProcessHtml(
|
850 | compiler,
|
851 | originalHtml,
|
852 | assetsInformationByGroups,
|
853 | assetTags,
|
854 | ) {
|
855 | let html = originalHtml;
|
856 |
|
857 | if (typeof html !== "string") {
|
858 | return Promise.reject(
|
859 | new Error(
|
860 | "Expected html to be a string but got " + JSON.stringify(html),
|
861 | ),
|
862 | );
|
863 | }
|
864 |
|
865 | if (this.options.inject) {
|
866 | const htmlRegExp = /(<html[^>]*>)/i;
|
867 | const headRegExp = /(<\/head\s*>)/i;
|
868 | const bodyRegExp = /(<\/body\s*>)/i;
|
869 | const metaViewportRegExp = /<meta[^>]+name=["']viewport["'][^>]*>/i;
|
870 | const body = assetTags.bodyTags.map((assetTagObject) =>
|
871 | htmlTagObjectToString(assetTagObject, this.options.xhtml),
|
872 | );
|
873 | const head = assetTags.headTags
|
874 | .filter((item) => {
|
875 | if (
|
876 | item.tagName === "meta" &&
|
877 | item.attributes &&
|
878 | item.attributes.name === "viewport" &&
|
879 | metaViewportRegExp.test(html)
|
880 | ) {
|
881 | return false;
|
882 | }
|
883 |
|
884 | return true;
|
885 | })
|
886 | .map((assetTagObject) =>
|
887 | htmlTagObjectToString(assetTagObject, this.options.xhtml),
|
888 | );
|
889 |
|
890 | if (body.length) {
|
891 | if (bodyRegExp.test(html)) {
|
892 |
|
893 | html = html.replace(bodyRegExp, (match) => body.join("") + match);
|
894 | } else {
|
895 |
|
896 | html += body.join("");
|
897 | }
|
898 | }
|
899 |
|
900 | if (head.length) {
|
901 |
|
902 | if (!headRegExp.test(html)) {
|
903 | if (!htmlRegExp.test(html)) {
|
904 | html = "<head></head>" + html;
|
905 | } else {
|
906 | html = html.replace(htmlRegExp, (match) => match + "<head></head>");
|
907 | }
|
908 | }
|
909 |
|
910 |
|
911 | html = html.replace(headRegExp, (match) => head.join("") + match);
|
912 | }
|
913 |
|
914 |
|
915 | if (assetsInformationByGroups.manifest) {
|
916 | html = html.replace(/(<html[^>]*)(>)/i, (match, start, end) => {
|
917 |
|
918 | if (/\smanifest\s*=/.test(match)) {
|
919 | return match;
|
920 | }
|
921 | return (
|
922 | start +
|
923 | ' manifest="' +
|
924 | assetsInformationByGroups.manifest +
|
925 | '"' +
|
926 | end
|
927 | );
|
928 | });
|
929 | }
|
930 | }
|
931 |
|
932 |
|
933 |
|
934 |
|
935 | const isProductionLikeMode =
|
936 | compiler.options.mode === "production" || !compiler.options.mode;
|
937 | const needMinify =
|
938 | this.options.minify === true ||
|
939 | typeof this.options.minify === "object" ||
|
940 | (this.options.minify === "auto" && isProductionLikeMode);
|
941 |
|
942 | if (!needMinify) {
|
943 | return Promise.resolve(html);
|
944 | }
|
945 |
|
946 | const minifyOptions =
|
947 | typeof this.options.minify === "object"
|
948 | ? this.options.minify
|
949 | : {
|
950 |
|
951 | collapseWhitespace: true,
|
952 | keepClosingSlash: true,
|
953 | removeComments: true,
|
954 | removeRedundantAttributes: true,
|
955 | removeScriptTypeAttributes: true,
|
956 | removeStyleLinkTypeAttributes: true,
|
957 | useShortDoctype: true,
|
958 | };
|
959 |
|
960 | try {
|
961 | html = require("html-minifier-terser").minify(html, minifyOptions);
|
962 | } catch (e) {
|
963 | const isParseError = String(e.message).indexOf("Parse Error") === 0;
|
964 |
|
965 | if (isParseError) {
|
966 | e.message =
|
967 | "html-webpack-plugin could not minify the generated output.\n" +
|
968 | "In production mode the html minification is enabled by default.\n" +
|
969 | "If you are not generating a valid html output please disable it manually.\n" +
|
970 | "You can do so by adding the following setting to your HtmlWebpackPlugin config:\n|\n|" +
|
971 | " minify: false\n|\n" +
|
972 | "See https://github.com/jantimon/html-webpack-plugin#options for details.\n\n" +
|
973 | "For parser dedicated bugs please create an issue here:\n" +
|
974 | "https://danielruf.github.io/html-minifier-terser/" +
|
975 | "\n" +
|
976 | e.message;
|
977 | }
|
978 |
|
979 | return Promise.reject(e);
|
980 | }
|
981 |
|
982 | return Promise.resolve(html);
|
983 | }
|
984 |
|
985 | |
986 |
|
987 |
|
988 |
|
989 | getAssetFiles(assets) {
|
990 | const files = _uniq(
|
991 | Object.keys(assets)
|
992 | .filter((assetType) => assetType !== "chunks" && assets[assetType])
|
993 | .reduce((files, assetType) => files.concat(assets[assetType]), []),
|
994 | );
|
995 | files.sort();
|
996 | return files;
|
997 | }
|
998 |
|
999 | |
1000 |
|
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 |
|
1006 |
|
1007 |
|
1008 |
|
1009 |
|
1010 | generateFavicon(
|
1011 | compiler,
|
1012 | favicon,
|
1013 | compilation,
|
1014 | publicPath,
|
1015 | previousEmittedAssets,
|
1016 | ) {
|
1017 | if (!favicon) {
|
1018 | return Promise.resolve(undefined);
|
1019 | }
|
1020 |
|
1021 | const filename = path.resolve(compilation.compiler.context, favicon);
|
1022 |
|
1023 | return promisify(compilation.inputFileSystem.readFile)(filename)
|
1024 | .then((buf) => {
|
1025 | const source = new compiler.webpack.sources.RawSource(
|
1026 | (buf),
|
1027 | false,
|
1028 | );
|
1029 | const name = path.basename(filename);
|
1030 |
|
1031 | compilation.fileDependencies.add(filename);
|
1032 | compilation.emitAsset(name, source);
|
1033 | previousEmittedAssets.push({ name, source });
|
1034 |
|
1035 | const faviconPath = publicPath + name;
|
1036 |
|
1037 | if (this.options.hash) {
|
1038 | return this.appendHash(
|
1039 | faviconPath,
|
1040 | (compilation.hash),
|
1041 | );
|
1042 | }
|
1043 |
|
1044 | return faviconPath;
|
1045 | })
|
1046 | .catch(() =>
|
1047 | Promise.reject(
|
1048 | new Error("HtmlWebpackPlugin: could not load file " + filename),
|
1049 | ),
|
1050 | );
|
1051 | }
|
1052 |
|
1053 | |
1054 |
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 |
|
1060 | generatedScriptTags(jsAssets) {
|
1061 |
|
1062 | return jsAssets.map((src) => {
|
1063 | const attributes = {};
|
1064 |
|
1065 | if (this.options.scriptLoading === "defer") {
|
1066 | attributes.defer = true;
|
1067 | } else if (this.options.scriptLoading === "module") {
|
1068 | attributes.type = "module";
|
1069 | } else if (this.options.scriptLoading === "systemjs-module") {
|
1070 | attributes.type = "systemjs-module";
|
1071 | }
|
1072 |
|
1073 | attributes.src = src;
|
1074 |
|
1075 | return {
|
1076 | tagName: "script",
|
1077 | voidTag: false,
|
1078 | meta: { plugin: "html-webpack-plugin" },
|
1079 | attributes,
|
1080 | };
|
1081 | });
|
1082 | }
|
1083 |
|
1084 | |
1085 |
|
1086 |
|
1087 |
|
1088 |
|
1089 |
|
1090 |
|
1091 | generateStyleTags(cssAssets) {
|
1092 | return cssAssets.map((styleAsset) => ({
|
1093 | tagName: "link",
|
1094 | voidTag: true,
|
1095 | meta: { plugin: "html-webpack-plugin" },
|
1096 | attributes: {
|
1097 | href: styleAsset,
|
1098 | rel: "stylesheet",
|
1099 | },
|
1100 | }));
|
1101 | }
|
1102 |
|
1103 | |
1104 |
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 | generateBaseTag(base) {
|
1110 | return [
|
1111 | {
|
1112 | tagName: "base",
|
1113 | voidTag: true,
|
1114 | meta: { plugin: "html-webpack-plugin" },
|
1115 |
|
1116 | attributes:
|
1117 | typeof base === "string"
|
1118 | ? {
|
1119 | href: base,
|
1120 | }
|
1121 | : base,
|
1122 | },
|
1123 | ];
|
1124 | }
|
1125 |
|
1126 | |
1127 |
|
1128 |
|
1129 |
|
1130 |
|
1131 |
|
1132 |
|
1133 | generatedMetaTags(metaOptions) {
|
1134 | if (metaOptions === false) {
|
1135 | return [];
|
1136 | }
|
1137 |
|
1138 |
|
1139 |
|
1140 |
|
1141 | const metaTagAttributeObjects = Object.keys(metaOptions)
|
1142 | .map((metaName) => {
|
1143 | const metaTagContent = metaOptions[metaName];
|
1144 | return typeof metaTagContent === "string"
|
1145 | ? {
|
1146 | name: metaName,
|
1147 | content: metaTagContent,
|
1148 | }
|
1149 | : metaTagContent;
|
1150 | })
|
1151 | .filter((attribute) => attribute !== false);
|
1152 |
|
1153 |
|
1154 |
|
1155 | return metaTagAttributeObjects.map((metaTagAttributes) => {
|
1156 | if (metaTagAttributes === false) {
|
1157 | throw new Error("Invalid meta tag");
|
1158 | }
|
1159 | return {
|
1160 | tagName: "meta",
|
1161 | voidTag: true,
|
1162 | meta: { plugin: "html-webpack-plugin" },
|
1163 | attributes: metaTagAttributes,
|
1164 | };
|
1165 | });
|
1166 | }
|
1167 |
|
1168 | |
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 |
|
1175 | generateFaviconTag(favicon) {
|
1176 | return [
|
1177 | {
|
1178 | tagName: "link",
|
1179 | voidTag: true,
|
1180 | meta: { plugin: "html-webpack-plugin" },
|
1181 | attributes: {
|
1182 | rel: "icon",
|
1183 | href: favicon,
|
1184 | },
|
1185 | },
|
1186 | ];
|
1187 | }
|
1188 |
|
1189 | |
1190 |
|
1191 |
|
1192 |
|
1193 |
|
1194 |
|
1195 |
|
1196 |
|
1197 |
|
1198 |
|
1199 |
|
1200 |
|
1201 |
|
1202 |
|
1203 | groupAssetsByElements(assetTags, scriptTarget) {
|
1204 |
|
1205 | const result = {
|
1206 | headTags: [...assetTags.meta, ...assetTags.styles],
|
1207 | bodyTags: [],
|
1208 | };
|
1209 |
|
1210 |
|
1211 |
|
1212 | if (scriptTarget === "body") {
|
1213 | result.bodyTags.push(...assetTags.scripts);
|
1214 | } else {
|
1215 |
|
1216 |
|
1217 | const insertPosition =
|
1218 | this.options.scriptLoading === "blocking"
|
1219 | ? result.headTags.length
|
1220 | : assetTags.meta.length;
|
1221 |
|
1222 | result.headTags.splice(insertPosition, 0, ...assetTags.scripts);
|
1223 | }
|
1224 |
|
1225 | return result;
|
1226 | }
|
1227 |
|
1228 | |
1229 |
|
1230 |
|
1231 |
|
1232 |
|
1233 |
|
1234 |
|
1235 |
|
1236 |
|
1237 |
|
1238 |
|
1239 |
|
1240 | replacePlaceholdersInFilename(compiler, filename, fileContent, compilation) {
|
1241 | if (/\[\\*([\w:]+)\\*\]/i.test(filename) === false) {
|
1242 | return { path: filename, info: {} };
|
1243 | }
|
1244 |
|
1245 | const hash = compiler.webpack.util.createHash(
|
1246 | compilation.outputOptions.hashFunction,
|
1247 | );
|
1248 |
|
1249 | hash.update(fileContent);
|
1250 |
|
1251 | if (compilation.outputOptions.hashSalt) {
|
1252 | hash.update(compilation.outputOptions.hashSalt);
|
1253 | }
|
1254 |
|
1255 | const contentHash = (
|
1256 | hash
|
1257 | .digest(compilation.outputOptions.hashDigest)
|
1258 | .slice(0, compilation.outputOptions.hashDigestLength)
|
1259 | );
|
1260 |
|
1261 | return compilation.getPathWithInfo(filename, {
|
1262 | contentHash,
|
1263 | chunk: {
|
1264 | hash: contentHash,
|
1265 |
|
1266 | contentHash,
|
1267 | },
|
1268 | });
|
1269 | }
|
1270 |
|
1271 | |
1272 |
|
1273 |
|
1274 |
|
1275 |
|
1276 |
|
1277 |
|
1278 |
|
1279 |
|
1280 |
|
1281 |
|
1282 |
|
1283 | generateHTML(
|
1284 | compiler,
|
1285 | compilation,
|
1286 | outputName,
|
1287 | childCompilerPlugin,
|
1288 | previousEmittedAssets,
|
1289 | assetJson,
|
1290 | callback,
|
1291 | ) {
|
1292 |
|
1293 | const entryNames = Array.from(compilation.entrypoints.keys());
|
1294 | const filteredEntryNames = this.filterEntryChunks(
|
1295 | entryNames,
|
1296 | this.options.chunks,
|
1297 | this.options.excludeChunks,
|
1298 | );
|
1299 | const sortedEntryNames = this.sortEntryChunks(
|
1300 | filteredEntryNames,
|
1301 | this.options.chunksSortMode,
|
1302 | compilation,
|
1303 | );
|
1304 | const templateResult = this.options.templateContent
|
1305 | ? { mainCompilationHash: compilation.hash }
|
1306 | : childCompilerPlugin.getCompilationEntryResult(this.options.template);
|
1307 |
|
1308 | if ("error" in templateResult) {
|
1309 | compilation.errors.push(
|
1310 | prettyError(templateResult.error, compiler.context).toString(),
|
1311 | );
|
1312 | }
|
1313 |
|
1314 |
|
1315 |
|
1316 | const isCompilationCached =
|
1317 | templateResult.mainCompilationHash !== compilation.hash;
|
1318 |
|
1319 | const assetsInformationByGroups = this.getAssetsInformationByGroups(
|
1320 | compilation,
|
1321 | outputName,
|
1322 | sortedEntryNames,
|
1323 | );
|
1324 |
|
1325 | const newAssetJson = JSON.stringify(
|
1326 | this.getAssetFiles(assetsInformationByGroups),
|
1327 | );
|
1328 |
|
1329 | if (
|
1330 | isCompilationCached &&
|
1331 | this.options.cache &&
|
1332 | assetJson.value === newAssetJson
|
1333 | ) {
|
1334 | previousEmittedAssets.forEach(({ name, source, info }) => {
|
1335 | compilation.emitAsset(name, source, info);
|
1336 | });
|
1337 | return callback();
|
1338 | } else {
|
1339 | previousEmittedAssets.length = 0;
|
1340 | assetJson.value = newAssetJson;
|
1341 | }
|
1342 |
|
1343 |
|
1344 |
|
1345 |
|
1346 | const assetsPromise = this.generateFavicon(
|
1347 | compiler,
|
1348 | this.options.favicon,
|
1349 | compilation,
|
1350 | assetsInformationByGroups.publicPath,
|
1351 | previousEmittedAssets,
|
1352 | ).then((faviconPath) => {
|
1353 | assetsInformationByGroups.favicon = faviconPath;
|
1354 | return HtmlWebpackPlugin.getCompilationHooks(
|
1355 | compilation,
|
1356 | ).beforeAssetTagGeneration.promise({
|
1357 | assets: assetsInformationByGroups,
|
1358 | outputName,
|
1359 | plugin: this,
|
1360 | });
|
1361 | });
|
1362 |
|
1363 |
|
1364 | const assetTagGroupsPromise = assetsPromise
|
1365 |
|
1366 | .then(({ assets }) =>
|
1367 | HtmlWebpackPlugin.getCompilationHooks(
|
1368 | compilation,
|
1369 | ).alterAssetTags.promise({
|
1370 | assetTags: {
|
1371 | scripts: this.generatedScriptTags(assets.js),
|
1372 | styles: this.generateStyleTags(assets.css),
|
1373 | meta: [
|
1374 | ...(this.options.base !== false
|
1375 | ? this.generateBaseTag(this.options.base)
|
1376 | : []),
|
1377 | ...this.generatedMetaTags(this.options.meta),
|
1378 | ...(assets.favicon
|
1379 | ? this.generateFaviconTag(assets.favicon)
|
1380 | : []),
|
1381 | ],
|
1382 | },
|
1383 | outputName,
|
1384 | publicPath: assetsInformationByGroups.publicPath,
|
1385 | plugin: this,
|
1386 | }),
|
1387 | )
|
1388 | .then(({ assetTags }) => {
|
1389 |
|
1390 | const scriptTarget =
|
1391 | this.options.inject === "head" ||
|
1392 | (this.options.inject !== "body" &&
|
1393 | this.options.scriptLoading !== "blocking")
|
1394 | ? "head"
|
1395 | : "body";
|
1396 |
|
1397 | const assetGroups = this.groupAssetsByElements(assetTags, scriptTarget);
|
1398 |
|
1399 | return HtmlWebpackPlugin.getCompilationHooks(
|
1400 | compilation,
|
1401 | ).alterAssetTagGroups.promise({
|
1402 | headTags: assetGroups.headTags,
|
1403 | bodyTags: assetGroups.bodyTags,
|
1404 | outputName,
|
1405 | publicPath: assetsInformationByGroups.publicPath,
|
1406 | plugin: this,
|
1407 | });
|
1408 | });
|
1409 |
|
1410 |
|
1411 | const templateEvaluationPromise = Promise.resolve().then(() => {
|
1412 | if ("error" in templateResult) {
|
1413 | return this.options.showErrors
|
1414 | ? prettyError(templateResult.error, compiler.context).toHtml()
|
1415 | : "ERROR";
|
1416 | }
|
1417 |
|
1418 |
|
1419 | if (this.options.templateContent !== false) {
|
1420 | return this.options.templateContent;
|
1421 | }
|
1422 |
|
1423 |
|
1424 | if ("compiledEntry" in templateResult) {
|
1425 | const compiledEntry = templateResult.compiledEntry;
|
1426 | const assets = compiledEntry.assets;
|
1427 |
|
1428 |
|
1429 | for (const name in assets) {
|
1430 | previousEmittedAssets.push({
|
1431 | name,
|
1432 | source: assets[name].source,
|
1433 | info: assets[name].info,
|
1434 | });
|
1435 | }
|
1436 |
|
1437 | return this.evaluateCompilationResult(
|
1438 | compiledEntry.content,
|
1439 | assetsInformationByGroups.publicPath,
|
1440 | this.options.template,
|
1441 | );
|
1442 | }
|
1443 |
|
1444 | return Promise.reject(
|
1445 | new Error("Child compilation contained no compiledEntry"),
|
1446 | );
|
1447 | });
|
1448 | const templateExecutionPromise = Promise.all([
|
1449 | assetsPromise,
|
1450 | assetTagGroupsPromise,
|
1451 | templateEvaluationPromise,
|
1452 | ])
|
1453 |
|
1454 | .then(([assetsHookResult, assetTags, compilationResult]) =>
|
1455 | typeof compilationResult !== "function"
|
1456 | ? compilationResult
|
1457 | : this.executeTemplate(
|
1458 | compilationResult,
|
1459 | assetsHookResult.assets,
|
1460 | { headTags: assetTags.headTags, bodyTags: assetTags.bodyTags },
|
1461 | compilation,
|
1462 | ),
|
1463 | );
|
1464 |
|
1465 | const injectedHtmlPromise = Promise.all([
|
1466 | assetTagGroupsPromise,
|
1467 | templateExecutionPromise,
|
1468 | ])
|
1469 |
|
1470 | .then(([assetTags, html]) => {
|
1471 | const pluginArgs = {
|
1472 | html,
|
1473 | headTags: assetTags.headTags,
|
1474 | bodyTags: assetTags.bodyTags,
|
1475 | plugin: this,
|
1476 | outputName,
|
1477 | };
|
1478 | return HtmlWebpackPlugin.getCompilationHooks(
|
1479 | compilation,
|
1480 | ).afterTemplateExecution.promise(pluginArgs);
|
1481 | })
|
1482 | .then(({ html, headTags, bodyTags }) => {
|
1483 | return this.postProcessHtml(compiler, html, assetsInformationByGroups, {
|
1484 | headTags,
|
1485 | bodyTags,
|
1486 | });
|
1487 | });
|
1488 |
|
1489 | const emitHtmlPromise = injectedHtmlPromise
|
1490 |
|
1491 | .then((html) => {
|
1492 | const pluginArgs = { html, plugin: this, outputName };
|
1493 | return HtmlWebpackPlugin.getCompilationHooks(compilation)
|
1494 | .beforeEmit.promise(pluginArgs)
|
1495 | .then((result) => result.html);
|
1496 | })
|
1497 | .catch((err) => {
|
1498 |
|
1499 |
|
1500 | compilation.errors.push(prettyError(err, compiler.context).toString());
|
1501 | return this.options.showErrors
|
1502 | ? prettyError(err, compiler.context).toHtml()
|
1503 | : "ERROR";
|
1504 | })
|
1505 | .then((html) => {
|
1506 | const filename = outputName.replace(
|
1507 | /\[templatehash([^\]]*)\]/g,
|
1508 | require("util").deprecate(
|
1509 | (match, options) => `[contenthash${options}]`,
|
1510 | "[templatehash] is now [contenthash]",
|
1511 | ),
|
1512 | );
|
1513 | const replacedFilename = this.replacePlaceholdersInFilename(
|
1514 | compiler,
|
1515 | filename,
|
1516 | html,
|
1517 | compilation,
|
1518 | );
|
1519 | const source = new compiler.webpack.sources.RawSource(html, false);
|
1520 |
|
1521 |
|
1522 | compilation.emitAsset(
|
1523 | replacedFilename.path,
|
1524 | source,
|
1525 | replacedFilename.info,
|
1526 | );
|
1527 | previousEmittedAssets.push({ name: replacedFilename.path, source });
|
1528 |
|
1529 | return replacedFilename.path;
|
1530 | })
|
1531 | .then((finalOutputName) =>
|
1532 | HtmlWebpackPlugin.getCompilationHooks(compilation)
|
1533 | .afterEmit.promise({
|
1534 | outputName: finalOutputName,
|
1535 | plugin: this,
|
1536 | })
|
1537 | .catch((err) => {
|
1538 |
|
1539 | (this.logger).error(err);
|
1540 | return null;
|
1541 | })
|
1542 | .then(() => null),
|
1543 | );
|
1544 |
|
1545 |
|
1546 |
|
1547 | emitHtmlPromise.then(() => {
|
1548 | callback();
|
1549 | });
|
1550 | }
|
1551 | }
|
1552 |
|
1553 |
|
1554 |
|
1555 |
|
1556 |
|
1557 |
|
1558 |
|
1559 |
|
1560 |
|
1561 |
|
1562 |
|
1563 |
|
1564 |
|
1565 |
|
1566 |
|
1567 | function templateParametersGenerator(compilation, assets, assetTags, options) {
|
1568 | return {
|
1569 | compilation: compilation,
|
1570 | webpackConfig: compilation.options,
|
1571 | htmlWebpackPlugin: {
|
1572 | tags: assetTags,
|
1573 | files: assets,
|
1574 | options: options,
|
1575 | },
|
1576 | };
|
1577 | }
|
1578 |
|
1579 |
|
1580 |
|
1581 |
|
1582 |
|
1583 | HtmlWebpackPlugin.version = 5;
|
1584 |
|
1585 |
|
1586 |
|
1587 |
|
1588 |
|
1589 |
|
1590 |
|
1591 | HtmlWebpackPlugin.getHooks = HtmlWebpackPlugin.getCompilationHooks;
|
1592 | HtmlWebpackPlugin.createHtmlTagObject = createHtmlTagObject;
|
1593 |
|
1594 | module.exports = HtmlWebpackPlugin;
|