Our goal is to configure webpack to build our assets so that any chunks that appear in any of these bundles will not appear in any other bundle.
What I had before:
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', minChunks: function (module, count) { // this assumes your vendor imports exist in the node_modules directory and module should be required // in at least 3 entries before it moved to common chunk return (module.context && module.context.indexOf('node_modules') !== -1) && count > 2; } }),
How it works now:
optimization: { splitChunks: { cacheGroups: { vendor: { test: /[\\/]node_modules[\\/]/, chunks: 'all', name: 'vendor', enforce: true, minChunks: 3 } } } },