UNPKG

1.38 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var HtmlWebpackPlugin = require("html-webpack-plugin");
4var cheerio_1 = require("cheerio");
5var fs_1 = require("fs");
6var path_1 = require("path");
7var helpers_1 = require("./helpers");
8var Html5EntryWebpackPlugin = /** @class */ (function () {
9 function Html5EntryWebpackPlugin(options) {
10 if (options === void 0) { options = {}; }
11 this.options = options;
12 }
13 Html5EntryWebpackPlugin.prototype.apply = function (compiler) {
14 var entry = compiler.options.entry;
15 var template = helpers_1.getTemplates(entry)[0];
16 if (template) {
17 var src_1 = path_1.dirname(template);
18 var templateContent = cheerio_1.load(fs_1.readFileSync(template, 'utf8'));
19 var entries = helpers_1.extractParts(templateContent).map(function (entry) { return path_1.join(src_1, entry); });
20 var plugins = [
21 new HtmlWebpackPlugin({
22 templateContent: templateContent.html(),
23 }),
24 ];
25 helpers_1.setEntries(compiler.options, template, entries);
26 plugins.forEach(function (plugin) { return plugin.apply(compiler); });
27 }
28 };
29 return Html5EntryWebpackPlugin;
30}());
31exports.Html5EntryWebpackPlugin = Html5EntryWebpackPlugin;
32//# sourceMappingURL=index.js.map
\No newline at end of file