gpt4 book ai didi

angular - 缓存图标 Ionic PWA Angular

转载 作者:行者123 更新时间:2023-12-04 14:17:09 25 4
gpt4 key购买 nike

我想知道是否有人可以帮助我。我使用 Ionic + Angular 开发 PWA 并使用 Firebase 托管它。事实是,当我失去互联网时, ionic 图标就绝望了......我无法弄清楚如何修改我的 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)"
]
}
}
]
}

最佳答案

添加一个新部分或像这样扩展现有部分:

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

关于angular - 缓存图标 Ionic PWA Angular,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59108335/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com