Skip to content

Commit

Permalink
feat(v2): better webpack splitchunks optimization (#1565)
Browse files Browse the repository at this point in the history
* feat(v2): better webpack splitchunks optimization

* tweak

* comment
  • Loading branch information
endiliey committed Jun 6, 2019
1 parent 937be4d commit a0777f7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/docusaurus/src/webpack/base.ts
Expand Up @@ -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',
Expand All @@ -90,7 +104,6 @@ export function createBaseConfig(
},
common: {
name: 'common',
chunks: 'all',
minChunks: 2,
priority: 10,
reuseExistingChunk: true,
Expand Down

0 comments on commit a0777f7

Please sign in to comment.