set NODE_ENV to production#393
set NODE_ENV to production#393theimowski merged 8 commits intoSAFE-Stack:masterfrom CallumVass:master
Conversation
| "scripts": { | ||
| "start": "webpack-dev-server", | ||
| "build": "webpack -p" | ||
| "build": "cross-env NODE_ENV=production webpack -p" |
There was a problem hiding this comment.
If this is "best practice" I'm wondering whether we should force it for minimal template - maybe just use the best practice for default template and let minimal users handle that themselves if necessary?
There was a problem hiding this comment.
I don't mind, I was just being consistent in applying it to both versions of the template as they both issue the same command but I can see your point. I'm happy to take it out of the minimal template? Let me know.
There was a problem hiding this comment.
yes please - let's keep the minimal minimal :)
There was a problem hiding this comment.
Hi, that's done. Thanks
|
Doesn't Running |
|
@kulshekhar Only in the bundle for runtime, it doesn't set it for build time. @CallumVass is there any reason not to just override it in webpack.config.js? process.env.NODE_ENV = isProduction ? "production" : ""Or how about setting I can just envision creating problems from having two sources of truth for the mode used in different places. |
|
The following statement from the webpack docs make me think
In this case, |
|
Just above that it says
|
|
My understanding of that statement (based on what follows) is that Edit: a quick glance at https://github.com/SAFE-Stack/SAFE-template/blob/master/Content/webpack.default.config.js#L52 indicates that the config file itself doesn't need the |
|
Hi, Setting -p flag when running webpack doesn't set NODE_ENV to production from what I saw with my issue. If you wanted me to put up a sample repo then I am more then happy to. I'm also not a front-end expert so setting it as part of the npm build script seemed the best place to me? @Zaid-Ajaj recommended it here too: #392 (comment) |
This seems like a good solution which
If an externally provided env variable is needed anyway, it might be better to use the |
|
Hi, I've set NODE_ENV inside the webpack.config now. Removed the cross-env dependency and reverted all my other changes. |
|
LGTM |
theimowski
left a comment
There was a problem hiding this comment.
Please also apply same changes to Content/webpack.tests.config.js to keep consistent
That's done. Thanks for reviewing. |
|
thanks! |
Fix #392