question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatically set NODE_ENV to production when build

See original GitHub issue

What problem does this feature solve?

Currently, I have to add cross-env into build script every time. (cross-env NODE_ENV=production vue-cli-service build).
If I don’t add it, build script will not minify files and extract CSS. (My laptop set NODE_ENV to development.)

What does the proposed API look like?

It should be great if vue-cli automatically define NODE_ENV to production when use vue-cli-service build with production mode. (It’s default)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
LinusBorgcommented, Jul 22, 2018

I assume you still have NODE_ENV defined globally on your system?

You can’t overwrite an environment variable set on your system with one in an .env file. As Evan alreay explained, and as the documentation explains (I think) - if you have set an environment variable, vue-cli will never overwrite that.

That’s why cross-env works. it changes the environment variable on your system before vue-cli-service runs.

It’s specifically designed like that so people can overwrite stuff with environment variables, which is quite often required in CI/CD environments.

2reactions
Akryumcommented, Jul 22, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - does process.env.NODE_ENV sets to 'production ...
Inside in your project in Heroku, you can set all environments variables. Go in your project > settings > Config ...
Read more >
What is Node_ENV Production and How to Get it on Windows ...
If you are unfamiliar with NODE_ENV development, it's a configuration variable that can be set on macOS to control how Node.js is used....
Read more >
Don't be fooled by NODE_ENV - Sean Connolly
When reviewing pull requests, any use of NODE_ENV like the snippet below is an automatic flag . if (process.env.NODE_ENV === 'production') ...
Read more >
The effects of omitting NODE_ENV in your Express.js apps
We clearly see that by setting NODE_ENV to production the number of requests Node.js can handle jumps by around two-thirds while the CPU ......
Read more >
Create-react-app environments - Medium
The value of NODE_ENV is set automatically to development (when using npm start ), test (when using npm test ) or production (when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found