我有一个角走线,它确实在一个证书路径下运行,例如 https://host:port/path/
当我加载应用程序并运行ngsw-cache-bust时,它将忽略路径,并尝试直接从根路径https://host:port/script.js获取脚本,而不是从https://host:port/path/script.js获取脚本
我通过运行ng add @ angular / pwa添加了pwa
我尝试了几种注册方式,例如/ngsw-worker.js或./ngsw-worker.js,但似乎都无法解决
我们使用Angular 7.2.0
ngsw-config.json看起来像这样
`
{
"index": "/index.html",
"routes": {
"/": {
"prefix": false
},
"/scripts": {
"prefix": true
},
"/libraries": {
"prefix": true
}
},
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"./favicon.ico",
"./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)"
],
"urls": [
"https://fonts.googleapis.com/**"
]
}
}
]
}
`
任何帮助都会得到高度评价!
答案 0 :(得分:0)
我通过在package.json中的prod脚本中添加路径来解析id
"prod": "gulp copy-assets && ng build --prod --progress=false --base-href=/abcd/",