question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

webpack does not generate always unique chunk hashes

See original GitHub issue

Hello, 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:closed
  • Created 8 years ago
  • Reactions:5
  • Comments:42 (9 by maintainers)

github_iconTop GitHub Comments

6reactions
scinoscommented, Nov 11, 2017

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).

6reactions
jhnnscommented, Oct 21, 2016

As far as I’m understanding it, we have two issues here:

  • Some people are complaining about different hashes although the file content is the same @dmitry
  • Some people are complaining about the same hashes although the file content has changed @dtothefp

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found