Firebase CLI 更改托管目标

Tom*_*Tom 6 firebase firebase-hosting firebase-cli

我在 >Firebase >Hosting >Main 中有两个 Firebase 托管站点(https://console.firebase.google.com/u/0/project/example/hosting/main

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)
Run Code Online (Sandbox Code Playgroud)

这些是我的.firebaserc设置:

 {
  "targets": {
    "foobar": {
      "hosting": {
        "foobar": [
          "foobarWebApp"
        ]
      }
    },
    "example": {
      "hosting": {
        "foobar": [
          "foobarWebApp"
        ],
        "example": [
          "foobar"
        ]
      }
    }
  },
  "projects": {
    "default": "foobar"
  }
}
Run Code Online (Sandbox Code Playgroud)

Firebase CLI运行firebase deploy后,文件将部署到foob​​ar .web.app。如何将其更改为示例.web.app

我试过了,firebase deploy --only hosting:example但总是返回错误:发生意外错误。

Rya*_*yan 9

您是否正确设置了托管目标?

\n\n

在您的 CLI 中,

\n\n

firebase target:apply type target-name resource-name

\n\n
    \n
  • 输入 \xe2\x80\x94 相关的 Firebase 资源类型。对于您的情况,请使用hosting.
  • \n
  • target-name \xe2\x80\x94 您要部署到的托管站点的唯一标识符(可以是任何内容)
  • \n
  • 资源名称 \xe2\x80\x94 Firebase 项目中列出的托管站点的名称(根据您的情况foobarexample
  • \n
\n\n

为 Firebase 资源设置部署目标后,请在firebase.json配置文件中引用应用的目标名称。

\n\n

请参阅https://firebase.google.com/docs/cli/targets

\n\n

编辑:

\n\n

.firebaserc应该看起来像这样,(尽管运行上面的命令行语句应该已经为你改变了这一点,并且你需要更新的是)package.json

\n\n
"projects": {\n    "default": "project-name"\n},\n"targets": {\n    "project-name": {\n        "hosting": {\n            "example": [ // target-name\n                "example-website" // resource-name\n            ],\n            "foobar": [ // target-name\n                "foobar-website" // resource-name\n            ]\n        }\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n