sw无法成功提供清单的start

sw无法成功提供清单的start

本文介绍了Angular 6 @ angular/pwa-sw无法成功提供清单的start_url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用angular 6和@ angular/pwa软件包构建了PWA.

I've built a PWA using angular 6 and the @angular/pwa package.

我一直在尝试解决此问题,但是无论我做什么,我都遇到了start_url错误.我已经尝试过:

I've been trying to fix this but no matter what I do, I'm getting the start_url error. I have tried:

  • 使用绝对链接
  • 确保start_url在SW的范围内(sw在主文件夹中)
  • 使用文件名"/index.html",就像我在其他支持线程中看到的那样.
  • 每次清除所有浏览器历史记录和缓存.
  • 在@ angular/pwa软件包中搜索Github问题
  • 通常会在Google上搜索此PWA问题.

这是我的清单:

{
  "name": "BC Doc View",
  "short_name": "BCview",
  "theme_color": "#1976d2",
  "background_color": "#fafafa",
  "display": "standalone",
  "scope": "/",
  "start_url": "/",

在这段代码之后,只有一堆图标,与本文无关.

After this piece of code there's just a bunch of icons, irrelevant to this post.

我对服务人员的配置:

{
  "index": "/index.html",
  "assetGroups": [
    {
      "name": "BC Doc View",
      "installMode": "prefetch",
      "resources": {
        "files": [
          "/favicon.ico",
          "/index.html",
          "/*.css",
          "/*.js"
        ]
      }
    }, {
      "name": "assets",
      "installMode": "lazy",
      "updateMode": "prefetch",
      "resources": {
        "files": [
          "/assets/**"

我使用ng build --prod命令实际生产的服务人员是2200行代码,因此我认为在此处发布该代码无关紧要.

My actual produced service worker using the ng build --prod command is 2200 lines of code so I don't think it would be relevant to post that here.

不知道我在这个上缺少什么.

Have no idea what I'm missing on this one.

推荐答案

我已将此错误哭了3个小时,在将其发布到此处几分钟后,我找到了解决方法.

I've cried with this error for 3 hours, minutes after I post it here I found the solution.

我一直在将其测试到dev子域中,并像subdomain.domain.com/folder一样访问它

I've been testing this into a dev subdomain and accessing it like subdomain.domain.com/folder

将所有内容放入主文件夹后,我得到100 PWA分数.

Once I've put everything in the main folder I'm getting a 100 PWA score.

https://i.imgur.com/ex3Os87.png

我还没有优化性能.

这篇关于Angular 6 @ angular/pwa-sw无法成功提供清单的start_url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 09:01