【发布时间】:2020-10-07 02:10:15
【问题描述】:
版本
- “@angular/common”:“~9.0.0”
- “@angular/service-worker”:“~9.0.0”
说明
我使用 ng add @angular/pwa --project [app] 实现了 service-worker,Lighthouse 会将网络应用识别为 PWA。
突然,在一次部署到托管“安装”通知的 Firebase 后没有弹出,所以我检查了开发控制台。
清单仍然照常显示:
但是没有缓存:
运行 Lighthouse-Audit 时,出现以下错误:
start_url does not respond with a 200 when offline
ngsw-config.json
{
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html",
"/manifest.webmanifest",
"/*.css",
"/*.js"
]
}
}, {
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**",
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
]
}
}
]
}
manifest.webmanifest
{
"name": "App",
"short_name": "App",
"theme_color": "#5787b2",
"background_color": "#fafafa",
"display": "standalone",
"scope": "/",
"start_url": "/",
"icons": [
{
"src": "assets/icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "assets/icons/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
【问题讨论】:
标签: angular firebase-hosting lighthouse angular-service-worker