Created
September 11, 2019 17:29
-
-
Save andreasvirkus/52e8df310634207c46d937c2606a467b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See an excellent explanation over at | |
// https://medium.com/hackernoon/the-100-correct-way-to-split-your-chunks-with-webpack-f8a9df5b7758 | |
optimization: { | |
runtimeChunk: 'single', | |
splitChunks: { | |
chunks: 'all', | |
maxInitialRequests: Infinity, | |
// Default is 30kB, let's set it to 5kB | |
minSize: 5000, | |
cacheGroups: { | |
vendor: { | |
test: /[\\/]node_modules[\\/]/, | |
name(module) { | |
// Get the package name, e.g. node_modules/packageName | |
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1]; | |
// npm package names are URL-safe, but some servers don't like @ symbols | |
return `npm.${packageName.replace('@', '')}`; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment