version-control-webpack-plugin

1.0.4 • Public • Published

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!`);
      }
    });
}

Readme

Keywords

none

Package Sidebar

Install

npm i version-control-webpack-plugin

Weekly Downloads

0

Version

1.0.4

License

ISC

Unpacked Size

18.5 kB

Total Files

9

Last publish

Collaborators

  • hzpsky2008