1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var HtmlWebpackPlugin = require("html-webpack-plugin");
|
4 | var cheerio_1 = require("cheerio");
|
5 | var fs_1 = require("fs");
|
6 | var path_1 = require("path");
|
7 | var helpers_1 = require("./helpers");
|
8 | var Html5EntryWebpackPlugin = (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 | }());
|
31 | exports.Html5EntryWebpackPlugin = Html5EntryWebpackPlugin;
|
32 |
|
\ | No newline at end of file |