问题
webpack.config.js
module.exports = {
entry: {
app: './src/main.js',
},
output: {
path: path.resolve(__dirname, './dist/js/'),
publicPath: '/js/',
filename: '[name].js',
chunkFilename: 'chunk/[contenthash:32].js', // use contenthash here
hashDigestLength:32,
},
product a file 28024a27808de6fae79a1f5596584d3e.js
, but actually the content hash is 9c757e82e0a41d8e51228532a109a0d7
回答1:
webpack uses the old md4 hash algorithm. Also it runs this on the base64 encoded version of your file.
Most importantly, this is done on the non minified version of your file. So you can't check the md4 value by comparing the hash from the filename and the actual md4 hash of the final minified file. They will never match.
Source: https://webpack.js.org/plugins/hashed-module-ids-plugin/
来源:https://stackoverflow.com/questions/50224845/why-is-the-contenthash-different-in-webpack