What is the suggested way of setting ENV variables that are expected to show up in process.env? #346
-
I looked over the Shakapacker v7 guide as well as the example applications, but I didn't see any mention on how to set environment variables (i.e process.env.IMPORTANT_VAR) for a react application that rails also needs access to. Is there currently a prescribed approach to accomplishing this? |
Beta Was this translation helpful? Give feedback.
Answered by
Judahmeek
Aug 18, 2023
Replies: 1 comment 4 replies
-
Just define your env variable as you do usually. There shouldn't be any issue unless you are talking about a very specific feature. In this case, a detailed proposal can be a good start. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@demitrious-tom you're right that won't work.
Your options are to either pass the value as props to your bundled application or to use a webpack loader, such as https://webpack.js.org/plugins/define-plugin/, to set those environment variables at compile-time.