title: Webpack 4: hash and contenthash and chunkhash, when to use which?
body: <p>someone have suggested a <a href="https://stackoverflow.com/questions/35176489/what-is-the-purpose-of-webpack-hash-and-chunkhash">similar question</a> to this one, but it only explains the differences between those hashes.</p>
  
  <p><strong>BUT, I still can't figure out when should I choose <code>[hash]</code> instead of <code>[contenthash]</code>? Can someone show me an example situation?</strong></p>
  
  <p>=== previous body ===</p>
  
  <p>The webpack docs explain different hashes type as following:</p>
  
  <p><a href="https://webpack.js.org/configuration/output/#outputfilename" rel="noreferrer">https://webpack.js.org/configuration/output/#outputfilename</a></p>
  
  <p><strong>hash:</strong></p>
  
  <blockquote>
    <p>Unique hash generated for every build</p>
  </blockquote>
  
  <p><strong>contenthash:</strong></p>
  
  <blockquote>
    <p>Hashes generated for extracted content</p>
  </blockquote>
  
  <p><strong>chunkhash:</strong></p>
  
  <blockquote>
    <p>Hashes based on each chunks' content:</p>
  </blockquote>
  
  <p>I am still confused about when to use which type of the hashes.</p>
  
  <p><code>[hash]</code> is generated for every build, but after running webpack build multiple times with following config, I didn't find my hash changed.</p>
  
  <pre class="lang-js prettyprint-override"><code>module.exports = {
    output: {
      filename: '[name].[hash].js'
    }
  }
  </code></pre>
  
  <p>Webpack version 4.41.2</p>
  
  <p>I also find that the webpack config inside <code>react-scripts</code>  is using contenthash for js and css file, but hash for assets files like images, this is also confusing, why are they doing it that way, is <code>[hash]</code> the better option for binary files?</p>