usage:
npm install version-control-webpack-plugin --save-dev
add this plugin entity to webpack config. ex:
... if production
plugins: [new VersionControlWebpackPlugin()]
...
then will generate a webpack-version-control.json in your dist;
call checkVersion where you need. ex:
if (window._VERSION_CONTROL) {
window._VERSION_CONTROL.checkVersion(({ success, serverVersion, currentVersion }) => {
if (success) {
if (serverVersion !== currentVersion) {
if (isRwClient) {
// notice client to reflesh
} else {
window.location.reload(1);
}
}
} else {
console.warn(`check vresion failed!`);
}
});
}