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
{{ message }}
Repository navigation
Request - set NODE_ENV="production" on prod build/serve #2110
OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
OSX 10.11.6
Versions. Please run ng --version. If there's nothing outputted, please run
in a Terminal: node --version and paste the result here:
angular-cli: 1.0.0-beta.11-webpack.9-2
node: 6.5.0
os: darwin x64
Repro steps. Was this an app that wasn't created using the CLI? What change did you
do on your code? etc.
Include a npm package which uses React and run a prod-build/serve.
The log given by the failure. Normally this include a stack trace and some
more information. Warning: It looks like you're using a minified copy of the development build of React. When deploying React apps to production, make sure to use the production build which skips development warnings and is faster. See https://fb.me/react-minification for more details.
Mention any other details that might be useful.
This can be solved by setting the NODE_ENV to "production" on prod build (i.e. set process.env.NODE_ENV = 'production'; in build script). I'd be happy to submit a PR for this if interested.
We just want process.env.NODE_ENV to be envified to become "production" in the bundled code. We don’t actually care about process.env.NODE_ENV of the build scripts, just that you DefinePlugin({ "process.env.NODE_ENV": "\"production\"" }) when you build.
Thank you very much, @gaearon. @filipesilva this would require a change, maybe falls into future add-on system. Though implementing this would likely not collide or conflict as the use case is probably edge.
@TheLarkInn should this indeed use the future add-on system or is it ok to put this in the default production webpack configuration? Running into this issue as well, more then willing to put in a pull request.
Been trying to find a workaround for it without having to fork and run my own version of the angular-cli but running out of ideas.
Now that I think about it, can you not just set it manually via export NODE_ENV=production? You could even put it in a npm script export NODE_ENV=production && ng build -prod.
This seems to be a React specific thing and I'd rather not introduce changes to the build pipeline because of it.
That's because that check is being done runtime by Redux. What we need is the webpack define plugin to set NODE_ENV global variable within the bundle. It's not something React specific and it's probably gonna be needed for more packages.
@filipesilva I can understand that it's not very high on the priority list. I'm more then willing to create a PR for it so you guys can see if it doesn't have any undesirable side effects and what the impact would be?
Activity
filipesilva commentedon Sep 21, 2016
@TheLarkInn can you weigh in?
TheLarkInn commentedon Sep 21, 2016
@gaearon is there any other way to flip this flag? Just want to know our available options.
gaearon commentedon Sep 21, 2016
We just want
process.env.NODE_ENVto be envified to become"production"in the bundled code. We don’t actually care aboutprocess.env.NODE_ENVof the build scripts, just that youDefinePlugin({ "process.env.NODE_ENV": "\"production\"" })when you build.TheLarkInn commentedon Sep 21, 2016
Thank you very much, @gaearon. @filipesilva this would require a change, maybe falls into future add-on system. Though implementing this would likely not collide or conflict as the use case is probably edge.
Australhawk commentedon Oct 3, 2016
ng build --prod Should set NODE_ENV to production by default, im having this exact issue with Redux. Any workarounds?
rthewhite commentedon Oct 11, 2016
@TheLarkInn should this indeed use the future add-on system or is it ok to put this in the default production webpack configuration? Running into this issue as well, more then willing to put in a pull request.
Been trying to find a workaround for it without having to fork and run my own version of the angular-cli but running out of ideas.
filipesilva commentedon Oct 14, 2016
Now that I think about it, can you not just set it manually via
export NODE_ENV=production? You could even put it in a npm scriptexport NODE_ENV=production && ng build -prod.This seems to be a React specific thing and I'd rather not introduce changes to the build pipeline because of it.
danimbrogno commentedon Oct 14, 2016
@filipesilva Just tried your suggestion but it didn't seem to work for me.
Still results in
You are currently using minified code outside of NODE_ENV === 'production'.rthewhite commentedon Oct 14, 2016
That's because that check is being done runtime by Redux. What we need is the webpack define plugin to set NODE_ENV global variable within the bundle. It's not something React specific and it's probably gonna be needed for more packages.
filipesilva commentedon Oct 15, 2016
@rthewhite I'll reopen then, but haven't had any report outside of React/Redux so far so I have to say this isn't very high on the priority list.
rthewhite commentedon Oct 15, 2016
@filipesilva I can understand that it's not very high on the priority list. I'm more then willing to create a PR for it so you guys can see if it doesn't have any undesirable side effects and what the impact would be?
filipesilva commentedon Oct 15, 2016
That would be welcome, yes. I could bring up the implementation among the team and see what we decide.
fix(build): add react minification support
fix(build): add react minification support
fix(build): add react minification support
fix(build): add react minification support
fix(build): add react minification support
rthewhite commentedon Oct 18, 2016
Thank you for solving this, didn't get to making the PR yet. Great that it's implemented now 👍
fix(build): add react minification support
angular-automatic-lock-bot commentedon Sep 6, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
fix(build): add react minification support