Search code examples
javascripthtmlcsswebpackwebpack-2

Is there a way to include build number in webpack bundle output(css/js file)?


Right now I have an issue where deployed .js and .css files are cached by our clients browsers. Which means they have to do a hard refresh(CTRL+F5) in order to get the newest updated .js file from the server. This obviously isn't good.

I have seen it's common practice to force a versioning on the .js and .css files name extension, for example so that bundle.js would be named something along the lines of bundle.js?v={versionnumber}?

Another challenge would be to dynamically update this reference in an index.html file. Is there a way to do this in Webpack as well?


Solution

  • Did you read this chapter webpack-caching?

    We usually give a [hash] as part of bundle name.

    And for your second question, you can try html-webpack-plugin