Can anyone tell me the definition of the [contenthash]
which added in webpack@4.3.0
?
According to the source code, it’s definitely not the the hash of the content(source code or bundle result).
But it should be the hash of the content, just works like extract-text-webpack-plugin. right ?
and why using md4
algorithm while loader-utils using md5
?
@z827101859 I can’t tell you why webpack do it this way, but I can show you how webpack do it.
src/index.js
webpack.config.js
First of all, webpack using
md4
algorithm to create hash by default.Secondly, I hope you’re already familiar with the concept of
Chunk
andModule
. For this example, we have amain
chunk which contain the modulesrc/index.js
.Chunk
andModule
both have thehash
property. the good news is, we only need to figure out howmodule.hash
be created, by now.how
module.hash
be createdmodule
also has a private property called_buildHash
, and here is how it be generated.and the
module.hash
Finally, the contenthash