2

I have an Angular web application called "my-app". I created a project on Google Firebase and called it "my-app" as well. I deployed the Angular application to Firebase project "my-app". As a result, a site "my-app-*****" appeared. My app was accessible on "my-app-*****.web.app" address.

Then I created the second site in Hosting of the same project. I called it "my-app-dev". It got an address but was empty because nothing was deployed yet. I followed instructions from google: https://firebase.google.com/docs/hosting/multisites And even one question on StackOverflow: Firebase hosting deploy to other site I added targets and modified firebase.json. In the result, they looked like that:

firebase.json file content:

  "hosting": [
    {
      "target": "prod",
      "public": "www",
      "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ]
    },
    {
      "target": "dev",
      "public": "www",
      "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ]
    }
  ]
}

.firebaserc file content:

{
  "projects": {
    "default": "my-app-*****"
  },
  "targets": {
    "my-app-*****": {
      "hosting": {
        "dev": [
          "my-app-dev"
        ],
        "prod": [
          "my-app-*****"
        ]
      }
    }
  }
}

But I faced an error when I executed command firebase deploy --only hosting:dev However, when I executed command firebase deploy --only hosting:prod, everything was deployed without errors.

As a result, I am able to deploy my project to "my-app-*****" site, but I could not deploy my project to "my-app-dev" site. I want both sites to use same built files, that is why "public" was pointing to the same directory "www". Both sites located in the same Hosting of "my-app" project on Google Firebase.

Can someone please help me and explain what have I done wrong?

Alish_strong
  • 99
  • 1
  • 8
  • This isn't quite an answer to your question, but Firebase recommends using separate projects for different environments e.g. dev/staging instead of using multiple sites in the same project. You can then use `firebase use` or the `--project` flag to choose which site to deploy. – Michael Bleigh May 14 '20 at 16:38
  • Ok, but still, Firebase pointed about possibility to deploy to different sites of the project. Yet I face an issue in doing so. Now I really want to understand the proper way of deployment to multiple sites – Alish_strong May 14 '20 at 19:38
  • 1
    You said you got an error, but not what the error was. Run `firebase deploy --only hosting:dev --debug` and include relevant output in the question to help get further. – Michael Bleigh May 14 '20 at 21:12
  • 1
    @michael-bleigh, you are right, my mistake in question posting. The error message was as follows: `**Error:** Task hash of the task failed: retries exhausted after 6 attempts`. – Alish_strong May 15 '20 at 05:59
  • Sounds like it might be a bug in the CLI. Can you run with `--debug` and post an issue at https://github.com/firebase/firebase-tools/issues – Michael Bleigh May 15 '20 at 17:30
  • I'm encountering the same error. Have you found a resolution? – Drew Burnett Dec 17 '20 at 22:30

0 Answers0