vir us
vir us

Reputation: 10765

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.

Upvotes: 2

Views: 463

Answers (2)

Daniel Muñoz
Daniel Muñoz

Reputation: 1792

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.

functions
  emulator-tests
    config
      .runtimeconfig.staging.json // config for staging env
      .runtimeconfig.prod.json // config for prod env
  src
  .runtimeconfig.json // default config I had
  package.json

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

Upvotes: 1

lilalinux
lilalinux

Reputation: 3031

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.

Upvotes: 0

Related Questions