-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Ensure npm run build is in production mode #5934
Conversation
LGTM |
Codecov Report
@@ Coverage Diff @@
## master #5934 +/- ##
=======================================
Coverage 48.19% 48.19%
=======================================
Files 393 393
Lines 23600 23600
Branches 2630 2630
=======================================
Hits 11375 11375
Misses 12225 12225 Continue to review full report at Codecov.
|
If not, the current solution works as well. |
@xtinec The check happens in |
@kristw I was thinking something like this in
If not, totally cool with leaving as-is. |
@xtinec Thanks for suggesting. I tried but didn't work. BTW |
@@ -15,7 +15,7 @@ | |||
"dev": "webpack --mode=development --colors --progress --debug --watch", | |||
"dev-server": "webpack-dev-server --mode=development --progress", | |||
"prod": "node --max_old_space_size=4096 webpack --mode=production --colors --progress", |
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.
should we also add this to the prod
script? or delete this script? @mistercrunch do you know why this is here? airbnb doesn't use it, and iirc it was just setting an upper limit on the process, which also makes it take like 20 min.
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.
prod
is legacy at this point, we use build
, I don't fully understand the implications / differences...
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.
@kristw Aha, got it. Thanks for clarifying! 👍 The change looks good to go. 🚢
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.
I can do whatever you both decide. Please let me know. I don't know what prod
is for, so didn't touch it.
Thanks @xtinec . Always great to have second eye on.
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.
I found an old PR from 2016 that reduced the size to what it is today.
#1679
Seems like there is no harm deleting it as the reasoning is weakened today with RAMs getting bigger. 😄
We should probably update this bit in CONTRIBUTING.md
before deleting prod
and also make a note in UPDATING.md
in case anyone has npm/yarn run prod
in their build pipeline.
# Compile the Javascript and CSS in production/optimized mode for official releases
npm run prod
Thoughts? @mistercrunch @williaster @kristw
I'm also cool with this PR shipping as-is. Going to go ahead and approve now.
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.
Last I checked the tradeoffs between run build
and run prod
were that run prod
took much longer and was significantly smaller. I'm not sure exactly what it entails.
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.
Umm, how about merging this and make dropping npm run prod
as another PR so it will be more obvious.
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.
sgtm
Using
--mode=production
does not work with some modules. In particular,react-hot-loader
usesNODE_ENV
to decide whether to use empty shell or HMR code.See bundle size before / after this change.
p.s. I tried using
webpack.DefinePlugin({ 'process.env.NODE_ENV': mode })
to avoid hardcoding env variable in npm script but was not successful, so I settle with this.@williaster @xtinec