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; } }); 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')})] }, - ['