'Firebase emulator - provide custom name/path to runtimeconfig.json

Is there a way to provide .runtimeconfig.json location though a command line? Can't find any info on that.

Something like below?

firebase emulators:start --runtimeconfig ./path/to/.runtimeconfig-prod.json

I have two runtimeconfig.json: one for development and another for production and I'm looking for an easy way to switch emulator environment.

Note: my dev and prod applications are stored under two separate firebase projects.

Solution 1:[1]

As lilalinux said, you can set CLOUD_RUNTIME_CONFIG with the path of your config file.

This is how I did it.

I created configurations for two environments (staging and prod) inside functions/emulator-tests/config. This is part of my project structure.

      .runtimeconfig.staging.json // config for staging env
      .runtimeconfig.prod.json // config for prod env
  .runtimeconfig.json // default config I had

I installed cross-env and added two scripts in package.json

"scripts": {
  "emulate-staging": "cross-env CLOUD_RUNTIME_CONFIG=./emulator- tests/config/.runtimeconfig.staging.json firebase emulators:start",
  "emulate-prod": "cross-env CLOUD_RUNTIME_CONFIG=./emulator-tests/config/.runtimeconfig.prod.json firebase emulators:start"

Then, from inside the functions folder I can emulate using any of those two environment configurations by running the respective script: npm run emulate-staging or npm run emulate-prod

Source: https://github.com/firebase/firebase-tools/issues/629

Solution 2:[2]

You can specify the path and name via CLOUD_RUNTIME_CONFIG, e.g.: CLOUD_RUNTIME_CONFIG="../../.runtimeconfig.json" firebase emulators:start

The path can be absolute or relative to the location where it would be expected as default.


This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 lilalinux