Webpack has a caching mechanism:
https://webpack.js.org/guides/caching/
That allows you to generate a content hash for your JS files.
Suppose I'm building many JS files and I only want to use the content hash for one of them.
How do I do this in webpack?
You can use a function for the filename like:
output: {
filename: (pathData) => {
return (pathData.chunk.name === 'main') ? '[name].[contenthash].js' : '[name].js';
},
},
This will only add the hash to the main.js file, or whatever logic you want to use based on the pathData.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With