Catch template errors

This commit is contained in:
Jan Nicklas 2015-03-11 11:23:52 +01:00
parent c082bb8ccc
commit 19aef72570
1 changed files with 8 additions and 3 deletions

View File

@ -45,9 +45,14 @@ HtmlWebpackPlugin.prototype.apply = function(compiler) {
});
};
HtmlWebpackPlugin.prototype.emitHtml = function(compiler, htmlTemplateContent, templateParams, outputFilename) {
var html = tmpl(htmlTemplateContent, templateParams);
compiler.assets[outputFilename] = {
HtmlWebpackPlugin.prototype.emitHtml = function(compilation, htmlTemplateContent, templateParams, outputFilename) {
var html;
try {
html = tmpl(htmlTemplateContent, templateParams);
} catch(e) {
compilation.errors.push(new Error('HtmlWebpackPlugin: template error ' + e));
}
compilation.assets[outputFilename] = {
source: function() {
return html;
},