feat(v2): better webpack splitchunks optimization (#1565)

* feat(v2): better webpack splitchunks optimization

* tweak

* comment
This commit is contained in:
Endi 2019-06-06 14:49:44 +07:00 committed by GitHub
parent 937be4d231
commit a0777f7c57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -81,6 +81,20 @@ export function createBaseConfig(
cacheGroups: {
// disable the built-in cacheGroups
default: false,
vendor: {
test: /[\\/]node_modules[\\/]/,
priority: 30,
minSize: 250000,
name(module) {
// get the package name. E.g. node_modules/packageName/not/this/part
const packageName = module.context.match(
/[\\/]node_modules[\\/](.*?)([\\/]|$)/,
)[1];
// some servers don't like @ symbols as filename
return `${packageName.replace('@', '')}`;
},
},
vendors: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
@ -90,7 +104,6 @@ export function createBaseConfig(
},
common: {
name: 'common',
chunks: 'all',
minChunks: 2,
priority: 10,
reuseExistingChunk: true,