缓存图标离子PWA角度

时间:2019-11-29 16:32:17

标签: angular ionic-framework progressive-web-apps ionicons

我想知道是否有人可以帮助我。我使用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)"
        ]
      }
    }
  ]
}

1 个答案:

答案 0 :(得分:0)

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

{
      "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 configuration guide

中找到更多信息