I am currently trying to hash my javascript file. I was trying, unscssfully, to use chunckHash. I have now noticed HTMLWebpackPlugin allows me to hash a file and pass that file through to the HTML script tag, which is ideal. However, am I missing anything by not using chunckHash?
chunkhash is part of the code splitting method to reduce the main bundle and split sources into multiple small files.
The difference is you can prefix or suffix your chunks just like you would do it with hash but export them applying different filters or conditions for different paths/folders
/* Soucre: https://webpack.js.org/configuration/output/#outputchunkfilename */
output: {
chunkFilename: (pathData) => {
return pathData.chunk.name === 'main' ? '[name].js' : '[name]/[name].js';
},
}
Source chunkHash: https://webpack.js.org/configuration/output/
Source for code splitting method: https://webpack.js.org/guides/code-splitting/