Firebase-tools: Able to specify custom Firebase.json file path in cli

Created on 21 Jan 2019  路  5Comments  路  Source: firebase/firebase-tools

It would be great to have the ability to specify a firebase.json path in the CLI, and with this have the option to have multiple firebase config files.

example usecase:

I want to separate my functions into production and dev groups, since I have a couple of functions that are dev only for now. Since deploy is handled by a CI and I have hosting rewrite rules in my firebase.json, I would specify a production firebase json and a dev firebase json with their appropriate rules

exports.productionGroup = {
  function1: functions.exampleFunction1
};

exports.devGroup = {
  function1: functions.exampleFunction1,
  function2: functions.exampleFunction2
};

prod.firebase.json

{
  "hosting": {
    "public": "public",
    "rewrites": [
        {
          "source": "/api/exampleFunction1", "function": "productionGroup-exampleFunction1"
        }
      ]
  }
}

dev.firebase.json

{
  "hosting": {
    "public": "public",
    "rewrites": [
        {
          "source": "/api/exampleFunction1", "function": "devGroup-exampleFunction1"
        },
        {
          "source": "/api/exampleFunction2", "function": "devGroup-exampleFunction2"
        }
      ]
  }
}

To deploy:

firebase deploy --config dev.firebase.json

or

firebase deploy --config prod.firebase.json
feature request

Most helpful comment

Good news everyone! I got this approved by the API council so we're going to add a --config / -c flag to the Firebase CLI.

All 5 comments

See #590 for some workarounds.

+1 , It is really needed on Monorepos

I also want this.
So, for the time being, I implement predeploy.sh wihch overwrites firestore.rules based on $GCLOUD_PROJECT.

https://firebase.google.com/docs/cli/?hl=en#environment_variables

I'm working on a PR for this issue, but I see that there is still something missing for my initial suggested usecase to work. So I created a new issue #1125 to isolate part of the problem

Good news everyone! I got this approved by the API council so we're going to add a --config / -c flag to the Firebase CLI.

Was this page helpful?
0 / 5 - 0 ratings