我的解决方法与 Marks answer 略有不同。
在您的 firebase.json 文件中,您需要确保 Service Worker 和 index.html 文件没有被缓存。对我来说,主要问题是缓存的 index.html。
Webpack 会在每次构建时更改块名称,并从 /build 中删除以前的版本。因此,当它们没有被上传并且您的浏览器查看缓存的 index.html 文件时,它会导致白屏和错误。
我的 firebase.json 文件中包含以下内容。希望有帮助
{
"hosting": {
"public": "build",
"headers": [
{
"source": "/service-worker.js",
"headers": [
{
"key": "Cache-Control",
"value": "no-store"
}
]
},
{
"source": "/index.html",
"headers": [
{
"key": "Cache-Control",
"value": "no-store"
}
]
}
],
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
],
"source": "functions"
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
}
}