build: optimize bundle size by updating split strategy
This commit is contained in:
parent
188921c247
commit
43200a2844
@ -89,11 +89,19 @@ module.exports = {
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
splitChunks: {
|
splitChunks: {
|
||||||
chunks: "async",
|
chunks: "all",
|
||||||
cacheGroups: {
|
cacheGroups: {
|
||||||
vendors: {
|
vendors: {
|
||||||
test: /[\\/]node_modules[\\/]/,
|
test: /[\\/]node_modules[\\/]/,
|
||||||
name: "vendor",
|
// cacheGroupKey here is `commons` as the key of the cacheGroup
|
||||||
|
name(module, chunks, cacheGroupKey) {
|
||||||
|
const moduleFileName = module
|
||||||
|
.identifier()
|
||||||
|
.split("/")
|
||||||
|
.reduceRight((item) => item);
|
||||||
|
const allChunksNames = chunks.map((item) => item.name).join("~");
|
||||||
|
return `${cacheGroupKey}-${allChunksNames}-${moduleFileName}`;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user