This example shows how you can set environment variables when running Bazel, then access them inside your program.
- Use the
--define=some_env=some_valueoption to Bazel, as shown here inpackage.json - Bazel is hermetic, so if you want
some_envto be exposed into the environment of an action, it must be declared, usingconfiguration_env_vars = ["some_env"]as shown here inBUILD.bazel. - In your Node.js program, reference
process.env['some_env']as usual, shown here indefine.spec.js.