Skip to content

Commit 374e23e

Browse files
numicaljantimon
authored andcommitted
chunks passed to alter-assets event (#574)
1 parent d64827a commit 374e23e

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ HtmlWebpackPlugin.prototype.apply = function (compiler) {
133133
.then(result => {
134134
var html = result.html;
135135
var assets = result.assets;
136-
var chunks = result.chunks;
137136
// Prepare script and link tags
138137
var assetTags = this.generateAssetTags(assets);
139138
var pluginArgs = {head: assetTags.head, body: assetTags.body, plugin: this, chunks: chunks, outputName: this.childCompilationOutputName};

spec/BasicSpec.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,36 @@ describe('HtmlWebpackPlugin', function () {
750750
}, false, true);
751751
});
752752

753+
it('passes chunks to the html-webpack-plugin-alter-asset-tags event', function (done) {
754+
var chunks;
755+
var examplePlugin = {
756+
apply: function (compiler) {
757+
compiler.plugin('compilation', function (compilation) {
758+
compilation.plugin('html-webpack-plugin-alter-asset-tags', function (object, callback) {
759+
chunks = object.chunks;
760+
callback();
761+
});
762+
});
763+
}
764+
};
765+
testHtmlPlugin({
766+
entry: {
767+
app: path.join(__dirname, 'fixtures/index.js')
768+
},
769+
output: {
770+
path: OUTPUT_DIR,
771+
filename: '[name]_bundle.js'
772+
},
773+
plugins: [
774+
new HtmlWebpackPlugin(),
775+
examplePlugin
776+
]
777+
}, [], null, function () {
778+
expect(chunks).toBeDefined();
779+
done();
780+
}, false, true);
781+
});
782+
753783
it('allows events to add a no-value attribute', function (done) {
754784
var examplePlugin = {
755785
apply: function (compiler) {

0 commit comments

Comments
 (0)