Add support for minification using html-minifier

This commit is contained in:
Sebastien Barre 2015-04-04 13:27:49 -04:00 committed by Jan Nicklas
parent 26b9f28937
commit 8b97335192
1 changed files with 7 additions and 0 deletions

View File

@ -113,6 +113,13 @@ HtmlWebpackPlugin.prototype.emitHtml = function(compilation, htmlTemplateContent
if (this.options.inject) {
html = this.injectAssetsIntoHtml(html, templateParams);
}
if (templateParams.htmlWebpackPlugin.options.minify) {
var minify = require('html-minifier').minify;
var minify_options = templateParams.htmlWebpackPlugin.options.minify.constructor === Object ? templateParams.htmlWebpackPlugin.options.minify : {};
html = minify(html, minify_options);
}
compilation.assets[outputFilename] = {
source: function() {
return html;