question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to manage deployment stages with env vars

See original GitHub issue

Deploy pipelines (test, prod) based on environment vars are important for some apps.

As most static deploy options may not handle the npm run build by themselves (allowing to register stage specific env vars at design time), I think some README advice on how to manage stage specific env vars would be helpful to many.

Or perhaps an enhancement like STAGE=MYSTAGE npm run build which selects the REACT_APP_MYSTAGE_SOMEVAR env var?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
islahulcommented, Mar 7, 2017

Hi @kimcrab, this code block is a set of shell commands and need to be run in the shell/terminal. It should be run before you run commands like npm run build Once you export a variable, you can access it in the node environment(where your build scripts written using webpack/grunt/gulp run) using process.env. So above scripts will enable you to access variables using process.env.REACT_APP_BUILD_ENV Does this help? Happy to connect outside this issue thread in case you need anything else.

1reaction
kimcrabcommented, Mar 7, 2017

Thanks @islahul, now I totally understand the point. When I type export AWS_ACCESS_KEY_ID="XXXXXX" in terminal, It is just a variable saved inside my terminal and when I type npm run build, webpack access to this variable! Very simple but didn’t understand before. I just finished test case and now I know what to do! Thanks again! You saved my day!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Manage Environment Variables? - Humanitec
How to manage environment variables ? Read the full interview with DevOps Engineer Antoine Rougeot about the fear to break things, ...
Read more >
Serverless: Managing environment variables efficiently with ...
I recently started exploring the Serverless framework for managing and deploying our Lambda functions and found it to be extremely powerful.
Read more >
How To: Manage Serverless Environment Variables Per Stage ...
Using STAGES and ENVIRONMENT variables together can create a really powerful workflow for you and your development team.
Read more >
Setting up stage variables for a REST API deployment
Stage variables are name-value pairs that you can define as configuration attributes associated with a deployment stage of a REST API.
Read more >
Environment Variables: What They Are and How To Use Them
You can easily set up .env files in a local development environment. Unlike platform-native variable managers, you do not need to deploy your ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found