Webpack plugin that emits a json file contaning the build hash.
For each build, Webpack generates an in-memory hash allowing to know if two build outputs are the same or not.
This plug-in outputs a json file contaning this described build hash.
This can be especially useful when you want to check if a new version of a Single Page Application (SPA) runned by your user's browser is available. The SPA would then, periodically, compare the remote hash with the initial hash and trigger a reload in case of mismatch.
The output is a JSON object in the form:
{"hash":"68aaedf27867fc4cb95d"}
yarn add -D build-hash-webpack-plugin
In your webpack config include the plug-in. And add it to your config:
import BuildHashPlugin from 'build-hash-webpack-plugin';
// ...
module.exports = {
// ....
plugins: [new BuildHashPlugin()]
}
You can pass the following options:
Optional. build-hash.json
by default.
Name for the created json file.
new BuildHashPlugin({filename: 'build-hash.json'})