纯前端实现页面更新提醒-plugin-web-update-notification

326 阅读1分钟

一、安装

yarn add @plugin-web-update-notification/webpack -D

二、配置

public/index.html

    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />

vue.config.js

const { WebUpdateNotificationPlugin } = require('@plugin-web-update-notification/webpack')


  configureWebpack: {
    plugins: [
      new WebUpdateNotificationPlugin({
        logVersion: true,
        checkInterval: 1000 * 3,
        notificationConfig: { placement: 'topRight' }
      })
    ]
  },

三、打包

npm run build

image.png

四、使用http-server运行dist/index.html

http-server -p 5008

image.png

五、改变web_version_by_plugin.json中的version

可以看到弹框提示 image.png