23

how to deploy to other firebase hosting sites defined within the same project. I created multiple firebase hosting "sites". The command

firebase deploy

however always deploys to the first one. How can I specify that the static files get deployed to another "site" (and domain).

Thanks

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Stefan
  • 381
  • 1
  • 2
  • 4
  • 1
    Google blog on this: https://firebase.googleblog.com/2018/08/one-project-multiple-sites-plus-boost.html – User Mar 06 '20 at 11:48

2 Answers2

46

You have to add the other sites as deploy targets. If you have a second site named awesome-site-d3426:

$ firebase target:apply hosting awesome-app awesome-site-d3426

You'll likely have to do the same thing for the primary site.

Then tell Firebase what to deploy to which targets in firebase.json:

{
  "hosting": [
    {
      "target": "awesome-site",
      "public": "awesome-site/dist"
    },
    {
      ...
    }
  ]
}

You can then deploy all the sites at once(firebase deploy) or a specific site:

$ firebase deploy --only hosting:awesome-site
Dr.jacky
  • 3,341
  • 6
  • 53
  • 91
abraham
  • 46,583
  • 10
  • 100
  • 152
  • 4
    Great answer. Had a really hard time finding how to do this on the firebase cli documentation. Thanks Abraham! – David Haddad Feb 27 '19 at 11:21
  • 1
    Funny thing is that I only mads a small edit to the Hosting part of my firebase.json ie `"site": "mySitesName"` . And even weirder is it never worked when I specified `"public" : "mySitesName/dist"` or `"public" : "public"`.... it only deployed when i wrote `"public" : "."` .. seems like a fluke but the site is live and working – Yo Apps Nov 22 '19 at 16:53
  • seems the targets are superfluous. I just added the site id to firebase.json as the "target" and I was able to deploy to it – ekkis Aug 06 '21 at 00:24
5

To deploy to another site created in same firebase project. Update your firebase.json file as folow

{
  "hosting": {
    "site":"<site-name>",
    "public": ...,
    "ignore": [
      ...
    ],
    "rewrites": [
      ...
    ]
  }
}