webpack does not generate always unique chunk hashes
See original GitHub issueHello, we have noted that sometimes webpack generates the same hash for a chunk, even if the file content has been changed.
Due to this, changes sometimes are not propagated, we experience an error similar to #959 and we’re forced to clear the cache/CDN to make the things work.
We are using the following plugins in the given order:
ExtractTextPlugin
CommonsChunkPlugin
OccurenceOrderPlugin
WebpackAssetsMapPlugin //custom plugin, writes the json stats file to the disk
DeduplePlugin
UglifyJsPlugin
Let me know if you need further details, V.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:5
- Comments:42 (9 by maintainers)
Top Results From Across the Web
How to make webpack generate consistent hashes across ...
First, I tried using [contenthash] . I thought this would work because, unlike [hash] , it is based on the content of a...
Read more >Caching - webpack
Webpack provides a method of templating the filenames using bracketed strings called substitutions. The [contenthash] substitution will add a unique hash based ...
Read more >The 100% correct way to split your chunks with Webpack
The terms sound interchangeable, but are apparently not: Bundle splitting: creating more, smaller files (but loading them all on each network ...
Read more >rollup.js
During this step, Rollup will build the module graph and perform tree-shaking, but will not generate any output. On a bundle object, you...
Read more >Long-term caching of static assets with Webpack - codeburst
So how can we guarantee that clients always get the latest versions of assets without re-downloading all of them? Generating unique hashes for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As @le12484 recommended, I wrote https://www.npmjs.com/package/webpack-plugin-hash-output to precisely fix this problem. It guarantees that you’ll get a
[chunkhash]
that is always a hash of the content. It solves the two errors in this thread (as summarized by @jhnns).It even has the option to fail the compilation if, for whatever reason, that postcondition is not met (see option
validateOutput
).As far as I’m understanding it, we have two issues here:
Please note that webpack hashes the final result (chunks and assets), which means that loaders and plugins have been executed before. Thus it is possible that you don’t get the same hashes for the same file content, because you might have installed different versions of loaders and plugins (at least when using npm).
Same goes the other way round. For instance, if you’re using tree-shaking, you might get the same hashes for different file contents if unused code is removed.
It would be very helpful if you could reproduce the error without any plugin. @dtothefp maybe it’s an error with the sri-stats-webpack-plugin? Try to remove as much as the possible so that we can locate the error.