frontend-webpack-boilerplate icon indicating copy to clipboard operation
frontend-webpack-boilerplate copied to clipboard

Cache busting

Open dangelion opened this issue 3 years ago • 1 comments

Hi, how about adding an hash on compiled css and js when deploying to production?

dangelion avatar Jan 25 '22 08:01 dangelion

Hi @dangelion

If you want provide global hash to files, just simply turn in ON (hash: true) for HTMLWebpackPluginmethod at the beginning of the webpack.config.js

Another way to deal with it is to add manualny generated hash for your output file name, for example:

Without hash app.js: filename: 'js/[name].js'

With 6-char hash: filename: 'js/[name].[hash:6].js'

Hope I helped you. Best

mukaspc avatar Jul 08 '22 21:07 mukaspc

@dangelion are you OK with the answer from @mukaspc?

pnikolov avatar Feb 21 '23 10:02 pnikolov

Note - turning on hash only works on images and fonts in the default webpack config. The generated js and css file is untouched.

I was able to change it for js and css by adding (the missing) [hash:6] to the filenames.

devshack avatar Oct 10 '23 15:10 devshack