Skip to content

Instantly share code, notes, and snippets.

@vinayakhumberi
Last active March 30, 2020 09:29
Show Gist options
  • Save vinayakhumberi/d34593a345ab9dcb736e67f50e88e9ad to your computer and use it in GitHub Desktop.
Save vinayakhumberi/d34593a345ab9dcb736e67f50e88e9ad to your computer and use it in GitHub Desktop.
Webpack Performance 3
const path = require('path');
module.exports = {
entry: './path/to/my/entry/file.js',
output: {
filename: '[name].bundle.[contenthash].js'
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
// 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}`;
},
chunks: 'all'
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment