Vue CLI 4-清单中的PWA插件预缓存无法获取index.html且未注册服务工作者

问题描述 投票:0回答:1

将Vue CLI 3更新为CLI 4后,服务工作者停止注册。

环境:

Firebase hosting, 

"vue": "^2.6.10",
"vuex": "^3.1.1",
"firebase": "^7.2.3",
"vuetify": "^2.1.9",
"core-js": "^3.3.6",
...
 "@vue/cli-plugin-pwa": "^4.0.5",

enter image description here

enter image description here

我发现失败发生在/index.html页面上生成的precache-manifest文件中:

// precache-manifest.326028534d4ff40f4be7a15fc11e84c6.js
...
 {
    "revision": "7eeb3269c508ac628b85ccfaa20744ab",
    "url": "/index.html"
  },
...

我试图从workboxOptions禁用'skipWaiting',因为我使用了文档所述的延迟加载路由,但是它什么也没做:

pwa:{
  workboxOptions: {
    skipWaiting: false,
  }
}

网络标签中的错误是:enter image description here

如果我手动注释掉已编译的precache-manifest文件中的行,那么服务工作者将正常工作。我不明白。

vue.js progressive-web-apps vue-cli workbox
1个回答
0
投票

原来问题出在firebase.json的配置中,在托管部分中,我启用了"cleanUrls": true。删除它会使服务人员再次注册。

这是现在的样子,默认设置:

 "hosting": {
    "public": "dist",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  },
© www.soinside.com 2019 - 2024. All rights reserved.