简体   繁体   English

使用 Vue CLI 时如何更新最新的工作箱版本

[英]How to update the latest workbox version when using Vue CLI

I am using Vue CLI plugin - @vue/cli-plugin-pwa and Google workbox to build a PWA app.我正在使用 Vue CLI 插件 - @vue/cli-plugin-pwa 和 Google 工作箱来构建 PWA 应用程序。 I want to use the latest version of the workbox which is 5.1.2 however, when I use the workbox (webpack) plugin to generate service-worker.js file, it only contains the 4.3.1 version as below then I run build script:我想使用最新版本的工作箱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

Is there any way to configure to get the latest version when I bundle, for now, I need to modify manually.有没有什么办法在我bundle的时候配置获取最新版本,目前我需要手动修改。

Thanks all谢谢大家

Got the solution (test), use the ReplaceInFileWebpackPlugin plugin, then it worked, simple yet effective.得到解决方案(测试),使用 ReplaceInFileWebpackPlugin 插件,然后它起作用了,简单而有效。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM