Exclude chunks works now even if combined with dependency sort
This commit is contained in:
parent
f3e4ead0f5
commit
c54273563a
|
|
@ -1,6 +1,10 @@
|
|||
Change History
|
||||
==============
|
||||
|
||||
v2.20.0
|
||||
----
|
||||
* Exclude chunks works now even if combined with dependency sort
|
||||
|
||||
v2.19.0
|
||||
----
|
||||
* Add `html-webpack-plugin-alter-chunks` event for custom chunk sorting and interpolation
|
||||
|
|
|
|||
|
|
@ -41,10 +41,11 @@ module.exports.dependency = function (chunks) {
|
|||
// Add an edge for each parent (parent -> child)
|
||||
chunk.parents.forEach(function (parentId) {
|
||||
var parentChunk = nodeMap[parentId];
|
||||
if (!parentChunk) {
|
||||
throw new Error('Can not find chunk parent during dependency sort');
|
||||
// If the parent chunk does not exist (e.g. because of an excluded chunk)
|
||||
// we ignore that parent
|
||||
if (parentChunk) {
|
||||
edges.push([parentChunk, chunk]);
|
||||
}
|
||||
edges.push([parentChunk, chunk]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "html-webpack-plugin",
|
||||
"version": "2.19.0",
|
||||
"version": "2.20.0",
|
||||
"description": "Simplifies creation of HTML files to serve your webpack bundles",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
|
|
|
|||
|
|
@ -1163,6 +1163,35 @@ describe('HtmlWebpackPlugin', function () {
|
|||
/<script type="text\/javascript" src="common_bundle.js">.+<script type="text\/javascript" src="aTheme_bundle.js">.+<script type="text\/javascript" src="util_bundle.js">/], null, done);
|
||||
});
|
||||
|
||||
it('should sort the chunks by chunk dependencies even if a parent chunk is excluded', function (done) {
|
||||
testHtmlPlugin({
|
||||
entry: {
|
||||
util: path.join(__dirname, 'fixtures/util.js'),
|
||||
aTheme: path.join(__dirname, 'fixtures/theme.js')
|
||||
},
|
||||
output: {
|
||||
path: OUTPUT_DIR,
|
||||
filename: '[name]_bundle.js'
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
{ test: /\.css$/, loader: 'css-loader' }
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new CommonsChunkPlugin({
|
||||
name: 'common',
|
||||
filename: 'common_bundle.js'
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
chunksSortMode: 'dependency',
|
||||
excludeChunks: ['common']
|
||||
})
|
||||
]
|
||||
}, [
|
||||
/<script type="text\/javascript" src="aTheme_bundle.js">.+<script type="text\/javascript" src="util_bundle.js">/], null, done);
|
||||
});
|
||||
|
||||
it('should add the webpack compilation object as a property of the templateParam object', function (done) {
|
||||
testHtmlPlugin({
|
||||
entry: path.join(__dirname, 'fixtures/index.js'),
|
||||
|
|
|
|||
Loading…
Reference in New Issue