jsonfirebase-hostingfirebase-cli

Deploying to a specific target in Firebase Hosting


I have the following hosting targets in my firebase.json file

{
  "hosting": [
    {
      "target": "staging",
      "public": "build",
      "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
      ],
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ]
    },
    {
      "target": "production",
      "public": "build",
      "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
      ],
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ]
    }
  ]
}

And my firebaserc file contains the following:

{
  "projects": {
    "default": "project-name177137"
  },
  "targets": {
    "project-name177137": {
      "hosting": {
        "staging": [
          "project-name177137"
        ],
        "production": [
          "productionName"
        ]
      }
    }
  }
}

If I want to deploy to all I usually just do firebase deploy.

Now imagine I want to deploy to only staging for testing, what firebase command can I use to achieve that?

Thank you.


Solution

  • firebase deploy --only hosting:staging

    documentation