chunks passed to alter-assets event (#574)

This commit is contained in:
Mike Evans 2017-01-29 14:07:05 +00:00 committed by Jan Nicklas
parent 73a01bdcaf
commit 2d5c42ff18
2 changed files with 30 additions and 1 deletions

View File

@ -144,7 +144,6 @@ HtmlWebpackPlugin.prototype.apply = function (compiler) {
.then(function (result) {
var html = result.html;
var assets = result.assets;
var chunks = result.chunks;
// Prepare script and link tags
var assetTags = self.generateAssetTags(assets);
var pluginArgs = {head: assetTags.head, body: assetTags.body, plugin: self, chunks: chunks, outputName: self.childCompilationOutputName};

View File

@ -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) {