Created by: judewang
I found many people like me need to build and deploy to not only production server but also staging server. Since create-react-app is hard coded NODE_ENV to production during build time, I thought we can add another env variable to achieve this goal.
Here's the code examples:
In .env.staging
REACT_APP_SECRET=xxxx
In .env.production
REACT_APP_SECRET=yyyy
We can use DOTENV=staging npm run build to build our static files using .env.staging.
We also can add "build:staging": "DOTENV=staging npm run build" into scripts in our package.json and just run npm run build:staging to do the same thing. This way we can still get an optimized production build but for different deploy targets.
Reference to #2880 (closed) #790 (closed)