bazel-contrib / rules_nodejs

NodeJS toolchain for Bazel.
https://bazelbuild.github.io/rules_nodejs/
Apache License 2.0
725 stars 522 forks source link

How to set env vars with `react_scripts` #2845

Closed phlax closed 2 years ago

phlax commented 3 years ago

question

Relevant Rules

create-react-app example and associated rules

Description

Im struggling to set any env vars for my c-r-a app when building with rules_nodejs

Describe the solution you'd like

To be able to set env vars for an app - preferably by adding an .env file into the runtime or by setting env vars

Describe alternatives you've considered

I tried adding an .env file to _RUNTIME_DEPS but it seems to be ignored

I tried (not exhaustively) to set relevant vars via action_env - no dice

I tried setting env to the react_scripts rule, but it seems to be ignored

alexeagle commented 3 years ago

https://github.com/bazelbuild/rules_nodejs/blob/stable/examples/create-react-app/BUILD.bazel#L59 shows how to pass an environment variable to react-scripts. What makes you think your environment variable "seems to be ignored"? Would need more repro info to help with that.

phlax commented 3 years ago

What makes you think your environment variable "seems to be ignored"? Would need more repro info to help with that.

i tried passing through the host so that i could access from outside of a container (ie not listen on localhost)

i may not have tested this very thoroughly though, so i can check again when i am next working on this code

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had any activity for 90 days. It will be closed if no further activity occurs in two weeks. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!

github-actions[bot] commented 2 years ago

This issue was automatically closed because it went two weeks without a reply since it was labeled "Can Close?"