3

我想知道是否有人可以帮助我。我使用 Ionic + Angular 开发 PWA 并使用 Firebase 托管它。事实是当我失去互联网时,离子图标绝望......我无法弄清楚如何修改我的 ngsw-config.json 以使其正常工作..

这是我的 Service Worker 配置文件

{
  "$schema": "./node_modules/@angular/service-worker/config/schema.json",
  "index": "/index.html",
  "assetGroups": [
    {
      "name": "app",
      "installMode": "prefetch",
      "resources": {
        "files": [
          "/favicon.ico",
          "/assets/fonts/*",
          "node_modules/videogular2/fonts/videogular.css",
          "/index.html",
          "/*.css",
          "/*.js"
        ]
      }
    }, {
      "name": "assets",
      "installMode": "lazy",
      "updateMode": "prefetch",
      "resources": {
        "files": [
          "/assets/**",
          "/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
        ]
      }
    }
  ]
}
4

1 回答 1

3

添加新部分或扩展现有部分,如下所示:

{
      "name": "icons",
      "installMode": "prefetch", // Download as soon as possible, may cause big net usage
      "updateMode": "prefetch", // Use cached version
      "resources": {
        "files": [
          "/svg/*.svg", // Path or template for your icons (Fetches all of it)
          "/svg/concrete.svg" // You may use concrete ones only
        ]
      }
}

如果您有一个大型图标库,最好指定应用程序处于离线模式时应该可用的图标。您可以在此处找到更多信息Angular service-worker 配置指南

于 2019-12-04T20:02:20.133 回答