Why is the [contenthash] different in webpack?

匆匆过客 提交于 2019-12-11 06:20:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!