webpack-genius
Version:
**For chinese developers:** you'd better add taobao mirror before everything start. Or you may fail to install. ```bash yarn config set registry http://registry.npm.taobao.org ```
51 lines (50 loc) • 1.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Html = void 0;
var tslib_1 = require("tslib");
var path_1 = tslib_1.__importDefault(require("path"));
var PluginHandle_1 = require("./PluginHandle");
var html_webpack_plugin_1 = tslib_1.__importDefault(require("html-webpack-plugin"));
var Html = /** @class */ (function (_super) {
tslib_1.__extends(Html, _super);
function Html() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.clones = [];
_this.config = {
meta: false,
title: _this.genius.getPackageField('description') || _this.genius.getPackageField('name'),
minify: _this.genius.isHot() ? false : {
collapseWhitespace: true,
minifyJS: true,
minifyCSS: true,
removeComments: true,
},
};
return _this;
}
Html.prototype.setTemplate = function (relativePath) {
this.config.template = path_1.default.resolve(relativePath);
return this;
};
Html.prototype.setTitle = function (title) {
this.config.title = title;
return this;
};
Html.prototype.mergeConfig = function (config) {
this.config = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, this.config), config), { minify: typeof config.minify === 'object'
? tslib_1.__assign(tslib_1.__assign({}, this.config.minify), config.minify) : config.minify });
return this;
};
Html.prototype.clone = function () {
var plugin = new Html(this.genius);
this.clones.push(plugin);
return plugin;
};
Html.prototype.collect = function () {
return this.clones.concat(this).map(function (html) {
return new html_webpack_plugin_1.default(html.config);
});
};
return Html;
}(PluginHandle_1.PluginHandle));
exports.Html = Html;