You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have application settings that depends on the environment. You know, the classic config file that exports things in this way:
if (process.env.NODE_ENV === 'production') {
// export production key/values here
} else {
}
I'm trying to test my production configuration locally by running NODE_ENV=production npm start, however the NODE_ENV is always overwritten to development.
I ejected the code and realized that this is explicitly done at start.js script and webpack.DefinePlugin configuration, so I'm sure there were good reasons to do that. But, don't you guys think this is a very common pattern and something that probably other developers will try too?
I know #342 added support for custom variables and I could do something like REACT_APP_ENV=production npm start and change my code to rely on this variable instead, which is great, but I'm wondering if it wouldn't make this a little tricky, specially for people getting started with React.
The text was updated successfully, but these errors were encountered:
fcaldera
changed the title
Cannot test my production configuration locally with npm start
Cannot test my production configuration locally with NODE_ENV and npm start
Aug 14, 2016
Yeah, that could work @gaearon. But what if I have others environments than development and production? For example a test environment. What if I want to run my app locally with all the test settings for some reason?
Probably a custom variable like REACT_APP_ENV would be suitable for this. We would just have to indicate people in the documentation that NODE_ENV is reserved mainly for optimisation and should not be used as reference to manage permanent application settings.
Yes, it seems like if you want more control, you’d have to use your own variables.
It’s very easy to mess up NODE_ENV and end up with slow version of React in production. I’ve seen this too many times and I would prefer the tool to force it to be correct depending on operation (start, test, build), even at the cost of some additional hassle for power users.
I have application settings that depends on the environment. You know, the classic config file that exports things in this way:
I'm trying to test my production configuration locally by running
NODE_ENV=production npm start
, however theNODE_ENV
is always overwritten todevelopment
.I ejected the code and realized that this is explicitly done at
start.js
script andwebpack.DefinePlugin
configuration, so I'm sure there were good reasons to do that. But, don't you guys think this is a very common pattern and something that probably other developers will try too?I know #342 added support for custom variables and I could do something like
REACT_APP_ENV=production npm start
and change my code to rely on this variable instead, which is great, but I'm wondering if it wouldn't make this a little tricky, specially for people getting started with React.The text was updated successfully, but these errors were encountered: