Last active
March 30, 2020 09:29
-
-
Save vinayakhumberi/d34593a345ab9dcb736e67f50e88e9ad to your computer and use it in GitHub Desktop.
Webpack Performance 3
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
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