From 19aef72570d7874ad64461f16ad4c60faa3f2162 Mon Sep 17 00:00:00 2001 From: Jan Nicklas Date: Wed, 11 Mar 2015 11:23:52 +0100 Subject: [PATCH] Catch template errors --- index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 641347d..2d3cd30 100644 --- a/index.js +++ b/index.js @@ -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; },