【问题标题】:Angular 7 PWA - Font Awesome icons missing in offline modeAngular 7 PWA - 离线模式下缺少字体真棒图标
【发布时间】:2019-05-15 03:30:46
【问题描述】:

问题是在离线模式下,字体真棒图标没有显示出来。 在离线模式下,我可以看到“网络”选项卡中状态为失败的文件是

  1. 在 dist 文件夹中生成 &
  2. 在“应用程序”选项卡的缓存中 - 例如/fa-solid-900.fb493903265cad425ccd.woff2

非常感谢您对此的任何帮助。详情如下 - 提前致谢。

阿米特·科利

包文件中的相关条目是 -

"@angular/animations": "7.1.3",
"@angular/common": "7.1.3",
"@angular/compiler": "7.1.3",
"@angular/core": "7.1.3",
"@angular/forms": "7.1.3",
"@angular/http": "7.1.3",
"@angular/platform-browser": "7.1.3",
"@angular/platform-browser-dynamic": "7.1.3",
"@angular/pwa": "^0.10.6",
"@angular/router": "7.1.3",
"@angular/service-worker": "7.1.3",
"@fortawesome/fontawesome-free": "^5.5.0",

在 ngsw-config.json - ...

"/favicon.ico",
      "/index.html",
      "/*.css",
      "/*.js",
      "/*.woff",
      "/*.woff2",
      "/*.ttf",
      "/fontawesome-webfont*"
    ]

Manifest.json -

  "short_name": "TALSWeb",
  "theme_color": "#00A160",
  "background_color": "#fafafa",
  "display": "standalone",
  "scope": "/",
  "start_url": "/",

生成的ngsw.json文件摘录——

"assetGroups": [
    {
      "name": "app",
      "installMode": "prefetch",
      "updateMode": "prefetch",
      "urls": [
        "/fa-brands-400.659c4d58b00226541ef9.woff2",
        "/fa-brands-400.8b7a9afd7b95f62e6ee8.woff",
        "/fa-brands-400.b69de69a4ff8ca0abe96.ttf",
        "/fa-regular-400.0b5e3a5451fc62d9023c.woff",
        "/fa-regular-400.b48c48ea8457846a5695.ttf",
        "/fa-regular-400.bdadb6ce95c5a2e7b673.woff2",
        "/fa-solid-900.48f54f63d7711d0912a9.ttf",
        "/fa-solid-900.bcb927a742a8370b7664.woff",
        "/fa-solid-900.fb493903265cad425ccd.woff2",
        "/favicon.ico",
        "/index.html",
        "/main.cbcf9854dbe01b31ca0f.js",
        "/polyfills.fab331e3b568bcb25c34.js",
        "/runtime.a66f828dca56eeb90e02.js",
        "/scripts.8d6556ad089996471ba5.js",
        "/styles.e844927534017e9a8be0.css"
      ],

in offline mode missing files are in the cache.PNG

【问题讨论】:

    标签: angular font-awesome progressive-web-apps offline-caching angular-service-worker


    【解决方案1】:

    这是我的配置:

    "name": "assets",
      "installMode": "lazy",
      "updateMode": "prefetch",
      "resources": {
        "files": [
          "/assets/**",
          "/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)",
          "/*-es5*.js"
        ],
        "urls": [
          "https://fonts.googleapis.com/**"
        ]
      }
    

    【讨论】:

      【解决方案2】:

      对我来说,问题是 FA 查询中有版本号,因此导致工作箱没有缓存它,因为它认为它是另一种资源。

      因此需要设置ignoreURLParametersMatching参数,更多信息见文档:https://developers.google.com/web/tools/workbox/modules/workbox-precaching#ignore_url_parameters

      【讨论】:

        【解决方案3】:

        在ngsw-config.json文件中,需要输入assetGroup里面fontawesome css文件的整个cdn url/目录路径。

        这样它就可以在第一次加载时被缓存。

        【讨论】:

          猜你喜欢
          • 2018-09-08
          • 2023-04-10
          • 1970-01-01
          • 1970-01-01
          • 2020-12-17
          • 2021-04-15
          • 2013-12-06
          • 2020-09-04
          • 2014-01-16
          相关资源
          最近更新 更多