1 | "use strict";
|
2 | var __assign = (this && this.__assign) || function () {
|
3 | __assign = Object.assign || function(t) {
|
4 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5 | s = arguments[i];
|
6 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7 | t[p] = s[p];
|
8 | }
|
9 | return t;
|
10 | };
|
11 | return __assign.apply(this, arguments);
|
12 | };
|
13 | Object.defineProperty(exports, "__esModule", { value: true });
|
14 | exports.Html5EntryWebpackPlugin = void 0;
|
15 | var HtmlWebpackPlugin = require("html-webpack-plugin");
|
16 | var cheerio_1 = require("cheerio");
|
17 | var fs_1 = require("fs");
|
18 | var path_1 = require("path");
|
19 | var helpers_1 = require("./helpers");
|
20 | var Html5EntryWebpackPlugin = (function () {
|
21 | function Html5EntryWebpackPlugin(options) {
|
22 | if (options === void 0) { options = {}; }
|
23 | this.options = options;
|
24 | }
|
25 | Html5EntryWebpackPlugin.prototype.apply = function (compiler) {
|
26 | var entry = compiler.options.entry;
|
27 | var template = helpers_1.getTemplates(entry)[0];
|
28 | if (template) {
|
29 | var src_1 = path_1.dirname(template);
|
30 | var templateContent = cheerio_1.load(fs_1.readFileSync(template, 'utf8'));
|
31 | var entries = helpers_1.extractParts(templateContent).map(function (entry) { return path_1.join(src_1, entry); });
|
32 | var plugins = [
|
33 | new HtmlWebpackPlugin(__assign(__assign({}, this.options), { templateContent: templateContent.html() })),
|
34 | ];
|
35 | helpers_1.setEntries(compiler.options, template, entries);
|
36 | plugins.forEach(function (plugin) { return plugin.apply(compiler); });
|
37 | }
|
38 | };
|
39 | return Html5EntryWebpackPlugin;
|
40 | }());
|
41 | exports.Html5EntryWebpackPlugin = Html5EntryWebpackPlugin;
|
42 |
|
\ | No newline at end of file |