I have some non-sensitive data that I need to set to different values based on what environment node runs in staging
or production
. I believe accessing something like process.env.NODE_ENV
will not work within a react component itself, only in a server-side file, hence need a way to somehow pass this down to my react component.
It is simply to show if string "Staging" or "Production" inside the footer component.
Consider using the DefinePlugin:
Define free variables. Useful for having development builds with debug logging or adding global constants.
Example:
new webpack.DefinePlugin({ VERSION: JSON.stringify("5fa3b9"), BROWSER_SUPPORTS_HTML5: true, TWO: "1+1", "typeof window": JSON.stringify("object") })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With