Automatically set NODE_ENV to production when build
See original GitHub issueWhat 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:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
Relevant documentation