【问题标题】:How to update the latest workbox version when using Vue CLI使用 Vue CLI 时如何更新最新的工作箱版本
【发布时间】:2021-02-06 15:10:51
【问题描述】:

我正在使用 Vue CLI 插件 - @vue/cli-plugin-pwa 和 Google 工作箱来构建 PWA 应用程序。我想使用最新版本的工作箱 5.1.2 但是,当我使用工作箱(webpack)插件生成 service-worker.js 文件时,它只包含 4.3.1 版本如下然后我运行构建脚本:

importScripts("/precache-manifest.83bfba368ee78b40421bed00a145f5e0.js", "https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");

//etc

捆绑时有什么方法可以配置获取最新版本,目前需要手动修改。

谢谢大家

【问题讨论】:

    标签: vue.js webpack progressive-web-apps workbox


    【解决方案1】:

    得到解决方案(测试),使用 ReplaceInFileWebpackPlugin 插件,然后它工作,简单而有效。

    new ReplaceInFileWebpackPlugin([
      {
        dir: "dist",
        files: ["service-worker.js"],
        rules: [
          {
            search: "releases/4.3.1",
            replace: "releases/5.1.2",
          },
        ],
      },
    ]),

    【讨论】:

      猜你喜欢
      • 2020-03-08
      • 2018-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-26
      • 1970-01-01
      • 2019-09-05
      • 1970-01-01
      相关资源
      最近更新 更多