我在 >Firebase >Hosting >Main ( https://console.firebase.google.com/u/0/project/example/hosting/main ) 中有两个 Firebase 托管站点
1. **foobar**.web.app (default project from setup process)
2. **example**.web.app (added as an additional web app under the main project and linked for hosting)
这些是我的 .firebaserc 设置:
{
"targets": {
"foobar": {
"hosting": {
"foobar": [
"foobarWebApp"
]
}
},
"example": {
"hosting": {
"foobar": [
"foobarWebApp"
],
"example": [
"foobar"
]
}
}
},
"projects": {
"default": "foobar"
}
}
运行后 firebase 部署 来自 Firebase CLI 文件被部署到 foobar .web.app。怎么改成示例 .web.app?
我试过
firebase deploy --only hosting:example
但这总是返回错误:发生意外错误。
最佳答案
您是否正确设置了托管目标?
在您的 CLI 中,firebase target:apply type target-name resource-name
hosting
. foobar
或 example
为 Firebase 资源设置部署目标后,请在
firebase.json
中引用应用的目标名称。配置文件。见 https://firebase.google.com/docs/cli/targets
编辑:
您的
.firebaserc
应该看起来像这样,(虽然运行上面的命令行语句应该已经为你改变了,你需要更新的是 package.json
):"projects": {
"default": "project-name"
},
"targets": {
"project-name": {
"hosting": {
"example": [ // target-name
"example-website" // resource-name
],
"foobar": [ // target-name
"foobar-website" // resource-name
]
}
}
}
关于Firebase CLI 更改托管目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61331567/