jantimon / jantimon/html-webpack-plugin
[contenthash] doesn't match between the assets in hooks and emitted output
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 1.3k
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
## Current behaviour 💣
When using the `assetTags` from the callback of `alterAssetTags` or `alterAssetTagGroups` hooks (didn't test other hooks), the `contenthash` portion of the asset filename differs from the `contenthash` of the same asset in the emitted output.
For example:
given `filename: "bundle.[contenthash].js"`
In `alterAssetTags` hook, `assetTags.scripts[0].attributes.src` evaluates to:
`bundle.1817f49c37ed2ca083b2.js`
whereas in the final output and also the emitted `index.html` it is:
`bundle.2e55dea7e3e197f9902d.js`
## Expected behaviour ☀️
The content hashes in the hooks filename and in the emitted output should be the same.
### Reproduction Example 👾
https://github.com/psimk/html-plugin-contenthash-reproducible
## Environment 🖥
* Node.js v14.16.0
* OS: linux 5.4.0-72-generic
* NPM 6.14.11
* Webpack 5.34.0
* HTMLWebpackPlugin 5.3.1
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked html-plugin-contenthash-reproducible example and inspect the alterAssetTags and alterAssetTagGroups hook outputs alongside the emitted assets and index.html. Reproduce the mismatch under Webpack 5.34.0 and HTMLWebpackPlugin 5.3.1, then verify that the contenthash in hook asset tags matches the final emitted filename.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, webpack
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100