Firebase CLI更改托管目标

时间:2020-04-20 20:34:01

标签: firebase firebase-hosting firebase-cli

我在> Firebase>托管>主(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 CLI 运行 firebase部署后,文件被部署到 foobar .web .app 。如何将其更改为 示例 .web.app

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

3 个答案:

答案 0 :(得分:1)

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

在您的CLI中,

firebase target:apply type target-name resource-name

  • type-相关的Firebase资源类型。在您的情况下,请使用hosting
  • target-name-您要部署到的托管站点的唯一标识符(可以是任何内容)
  • resource-name-Firebase项目中列出的托管站点的名称,在您的情况下为foobarexample

为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
            ]
        }
    }
}

答案 1 :(得分:1)

我认为可以将其分解为“确定性描述变量”

.firebaserc文件

{
  "targets": {
    "firebaseProjectID": {
      "hosting": {
        "targetValueInFirebase.json": [
          "yourFirebaseHostingDomain"
        ]
      }
    }
  },
  "projects": {
    "cli_alias": "firebaseProjectID"
  }
}

答案 2 :(得分:0)

我遇到了同样的问题并通过这个解决了

  • 1.<Record y.name='d' n.value=None> , 2.delete browser cache , 3.reopen browser 4.run deploy again*