tree: ad1a1d2c1367f6c4a8c3edc1a2436b8fa2f0f5d4
  1. BUILD.bazel
  2. define.spec.js
  3. package.json
  4. README.md
  5. WORKSPACE
  6. yarn.lock
examples/define_var/README.md

Defining environment variables

This example shows how you can set environment variables when running Bazel, then access them inside your program.

  1. Use the --define=some_env=some_value option to Bazel, as shown here in package.json
  2. Bazel is hermetic, so if you want some_env to be exposed into the environment of an action, it must be declared, using configuration_env_vars = ["some_env"] as shown here in BUILD.bazel.
  3. In your Node.js program, reference process.env['some_env'] as usual, shown here in define.spec.js.