- Application modules change often, but third party libraries do not
- Third party libraries can often be a large part of our overall output
- We often want to cache libraries separately from our application code
- Webpack allows us to split our bundle into separate chunked files
var config = {
...
output: {
filename: '[name].[contenthash].bundle.js'
},
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
name: 'vendor',
chunks: 'all',
test: /node_modules/
}
},
}
}
}