Hash in a build file in Webpack
We've already discussed the problem of file caching. Webpack can easily solve this problem. Webpack allows you to append a special hash to the file name, which is a unique random string generated based on the contents of the build file.
This means that with each new build, if changes were made to the project files, the hash of the build file will also change.
You can add a hash to a file name using a special command [contenthash]. Let's do it:
export default {
entry: [
'./src/test1.js',
'./src/test2.js'
],
output: {
filename: 'build.[contenthash].js',
}
};
Add the hash to your build file name. Build the project. Look at the file name.
Make a change to the project files. Build the project. Look at the name of the new file.