From 374e23eadd478738dfb8125cb59b31cf91cb3ba9 Mon Sep 17 00:00:00 2001 From: Mike Evans Date: Sun, 29 Jan 2017 14:07:05 +0000 Subject: [PATCH] chunks passed to alter-assets event (#574) --- index.js | 1 - spec/BasicSpec.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index f1bf0fc..7a47d6d 100644 --- a/index.js +++ b/index.js @@ -133,7 +133,6 @@ HtmlWebpackPlugin.prototype.apply = function (compiler) { .then(result => { var html = result.html; var assets = result.assets; - var chunks = result.chunks; // Prepare script and link tags var assetTags = this.generateAssetTags(assets); var pluginArgs = {head: assetTags.head, body: assetTags.body, plugin: this, chunks: chunks, outputName: this.childCompilationOutputName}; diff --git a/spec/BasicSpec.js b/spec/BasicSpec.js index 4a46d3a..17c960c 100644 --- a/spec/BasicSpec.js +++ b/spec/BasicSpec.js @@ -750,6 +750,36 @@ describe('HtmlWebpackPlugin', function () { }, false, true); }); + it('passes chunks to the html-webpack-plugin-alter-asset-tags event', function (done) { + var chunks; + var examplePlugin = { + apply: function (compiler) { + compiler.plugin('compilation', function (compilation) { + compilation.plugin('html-webpack-plugin-alter-asset-tags', function (object, callback) { + chunks = object.chunks; + callback(); + }); + }); + } + }; + testHtmlPlugin({ + entry: { + app: path.join(__dirname, 'fixtures/index.js') + }, + output: { + path: OUTPUT_DIR, + filename: '[name]_bundle.js' + }, + plugins: [ + new HtmlWebpackPlugin(), + examplePlugin + ] + }, [], null, function () { + expect(chunks).toBeDefined(); + done(); + }, false, true); + }); + it('allows events to add a no-value attribute', function (done) { var examplePlugin = { apply: function (compiler) {