From e5a210c60db2df2a5aa33e8e0dd12353814b9c3d Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 26 May 2015 13:07:30 +0100 Subject: [PATCH 1/2] Change assets deprecation from error to warning --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index c2fe8aa..05fdad7 100644 --- a/index.js +++ b/index.js @@ -36,7 +36,7 @@ HtmlWebpackPlugin.prototype.apply = function(compiler) { var assets = self.htmlWebpackPluginLegacyAssets(compilation, webpackStatsJson); Object.defineProperty(templateParams.htmlWebpackPlugin, 'assets', { get: function() { - compilation.errors.push(new Error('HtmlWebPackPlugin: htmlWebpackPlugin.assets is deprecated - please use htmlWebpackPlugin.files instead')); + compilation.warnings.push(new Error('HtmlWebPackPlugin: htmlWebpackPlugin.assets is deprecated - please use htmlWebpackPlugin.files instead')); return assets; } }); From 9557db2db0013603a722a6407b603aadda52ce63 Mon Sep 17 00:00:00 2001 From: "chris.greening" Date: Sun, 31 May 2015 14:32:07 +0100 Subject: [PATCH 2/2] Modifies unit tests to support expecting warnings --- spec/HtmlWebpackPluginSpec.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/spec/HtmlWebpackPluginSpec.js b/spec/HtmlWebpackPluginSpec.js index 1896fce..75ec141 100644 --- a/spec/HtmlWebpackPluginSpec.js +++ b/spec/HtmlWebpackPluginSpec.js @@ -8,7 +8,7 @@ var HtmlWebpackPlugin = require('../index.js'); var OUTPUT_DIR = path.join(__dirname, '../dist'); -function testHtmlPlugin(webpackConfig, expectedResults, outputFile, done, expectErrors) { +function testHtmlPlugin(webpackConfig, expectedResults, outputFile, done, expectErrors, expectWarnings) { outputFile = outputFile || 'index.html'; webpack(webpackConfig, function(err, stats) { expect(err).toBeFalsy(); @@ -18,6 +18,12 @@ function testHtmlPlugin(webpackConfig, expectedResults, outputFile, done, expect } else { expect(compilationErrors).toBe(''); } + var compilationWarnings = (stats.compilation.warnings || []).join('\n'); + if (expectWarnings) { + expect(compilationWarnings).not.toBe(''); + } else { + expect(compilationWarnings).toBe(''); + } var htmlContent = fs.readFileSync(path.join(OUTPUT_DIR, outputFile)).toString(); for (var i = 0; i < expectedResults.length; i++) { var expectedResult = expectedResults[i]; @@ -172,7 +178,7 @@ describe('HtmlWebpackPlugin', function() { }, plugins: [new HtmlWebpackPlugin({template: path.join(__dirname, 'fixtures/legacy.html')})] }, - ['