0

Sometimes, for some reason, webpack emits assets with identical content. In the plugin I'm writing now, I need to make sure that the asset content has changed. I'm using compiler.hooks.done hook and stats.compilation.emittedAssets argument to determine emitted assets. To make sure that asset content has changed, I'm going to use contenthash.

I've read the webpack documentation, but I can't figure out how to get asset contenthash inside the plugin. Is this even possible? Does webpack calculates contenthash without additional tuning? Or do I have to calculate the asset hash on my own?

Levap
  • 67
  • 4

1 Answers1

0

For webpack5 it is available in stats.compilation.assetsInfo

This is a map of AssetInfo objects that have the contenthash property

fela
  • 679
  • 8
  • 7