split bundle into multiple pieces with custom specifications
extension of CommonsChunkPlugin
yarn add webpack-split-plugin --dev
npm i webpack-split-plugin --save-dev
const WebpackSplitPlugin = require('webpack-split-plugin')
// also exported for convenience
const {CollectionManager, custom, match, version, log} = WebpackSplitPlugin
plugins: [
new WebpackSplitPlugin({
// * required
name: 'eh',
filename: '[name]-split.js',
// [optional], very verbose output
debug: true,
// [optional], automatically figures it out after first run
totalSize: '1937kb', // 1.937mb
}),
],
new WebpackSplitPlugin({
debug: 'verbose',
filename: '[name]-split.js',
custom: custom.splits({
// order of specificity
eh: ['moment'],
react: ['react'],
moose: [/noop/],
igloo: [file => (/plx/).test(file)],
canada: ['src/*.js'],
}),
})