-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define NODE_ENV on client-side in real world example #1605
Conversation
Right now NODE_ENV is always undefined on the client-side. This fix allows NODE_ENV to be defined, thus giving us the option to run the app in production mode (currently it'll only run in dev mode - see configureStore.js).
new webpack.HotModuleReplacementPlugin(), | ||
new webpack.DefinePlugin({ | ||
'process.env': { | ||
NODE_ENV: JSON.stringify(process.env.NODE_ENV) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Afaik this won't work since we don't define the NODE_ENV
in the start command, so process.env.NODE_ENV
will be undefined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do this, then:
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That won't work either, it'll never be in production. We don't even have a script to run this in production, see the package.json: https://github.com/JeremyBernier/redux/blob/patch-1/examples/real-world/package.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea it would be undefined if you ran npm start
, but not if you ran NODE_ENV=production npm start
These examples are meant as Redux examples, not as boilerplates you can run and bundle completely. I’d welcome an effort adding an |
I’ll close this specific PR but please feel free to submit another one that converts all examples to have a proper build. |
Yea it's definitely not a complete solution, but I figured it would only help to add since the example currently checks for |
Not quite sure what you mean. It’s fine for it to be undefined in dev. And the examples are not production-ready anyway so just fixing this one issue might actually make it worse because it’ll give the impression that they are production-ready whereas in reality there is more work to do here. |
Right now NODE_ENV is always undefined on the client-side. This fix allows NODE_ENV to be defined, thus giving us the option to run the app in production mode (currently it'll only run in dev mode - see configureStore.js).