Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Set minChunks to 2 by default in CommonChunksPlugin #412

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/configure-webpack/build-pages-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function configurePlugins (pages, action) {
})

if (pages.length > 1) {
plugins.push(new optimize.CommonsChunkPlugin({ name: 'common' }))
plugins.push(new optimize.CommonsChunkPlugin({ name: 'common', minChunks: 2 }))
}

return plugins
Expand Down
7 changes: 7 additions & 0 deletions src/configure-webpack/build-pages-config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ describe('pages webpack preset', function () {
const commons = webpackConfig.plugins.filter((plugin) => plugin instanceof optimize.CommonsChunkPlugin)
expect(commons.length).equal(1)
})

it('should set minChunks to 2 in the CommonsChunkPlugin', function () {
const webpackConfig = buildPagesConfig(['index', 'demo'], baseConfig)

const commons = webpackConfig.plugins.filter((plugin) => plugin instanceof optimize.CommonsChunkPlugin)
expect(commons[0].minChunks).equal(2)
})
})

describe(`when action is "${actions.BUILD}"`, () => {
Expand Down