Skip to content

Request - set NODE_ENV="production" on prod build/serve #2110

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

Closed
vicrep opened this issue Sep 14, 2016 · 14 comments
Closed

Request - set NODE_ENV="production" on prod build/serve #2110

vicrep opened this issue Sep 14, 2016 · 14 comments
Labels
P5 The team acknowledges the request but does not plan to address it, it remains open for discussion

Comments

@vicrep
Copy link

vicrep commented Sep 14, 2016

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
    OSX 10.11.6
  2. 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
  3. 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.
  4. 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.
  5. 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.

Thanks! We'll be in touch soon.

@filipesilva filipesilva added the needs: investigation Requires some digging to determine if action is needed label Sep 21, 2016
@filipesilva
Copy link
Contributor

@TheLarkInn can you weigh in?

@TheLarkInn
Copy link
Member

@gaearon is there any other way to flip this flag? Just want to know our available options.

@gaearon
Copy link

gaearon commented Sep 21, 2016

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.

@TheLarkInn
Copy link
Member

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
Copy link

ng build --prod Should set NODE_ENV to production by default, im having this exact issue with Redux. Any workarounds?

@rthewhite
Copy link

@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
Copy link
Contributor

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.

@danimbrogno
Copy link

@filipesilva Just tried your suggestion but it didn't seem to work for me.

"scripts": {
    "build": "export NODE_ENV=production && ng build --prod",
    "prepublish": "npm run build"
  }

Still results in

You are currently using minified code outside of NODE_ENV === 'production'.

@rthewhite
Copy link

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
Copy link
Contributor

@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.

@filipesilva filipesilva reopened this Oct 15, 2016
@filipesilva filipesilva added type: enhancement P5 The team acknowledges the request but does not plan to address it, it remains open for discussion and removed needs: investigation Requires some digging to determine if action is needed labels Oct 15, 2016
@rthewhite
Copy link

rthewhite commented 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
Copy link
Contributor

That would be welcome, yes. I could bring up the implementation among the team and see what we decide.

filipesilva added a commit to filipesilva/angular-cli that referenced this issue Oct 18, 2016
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Oct 18, 2016
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Oct 18, 2016
filipesilva added a commit that referenced this issue Oct 18, 2016
@rthewhite
Copy link

Thank you for solving this, didn't get to making the PR yet. Great that it's implemented now 👍

kieronqtran pushed a commit to kieronqtran/angular-cli that referenced this issue Oct 21, 2016
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P5 The team acknowledges the request but does not plan to address it, it remains open for discussion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants