-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
npm run build --mode [.env.mode] not working as expected #1528
Comments
This is related to how npm passes arguments to scripts when using
In other words: all arguments before |
@LinusBorg There is no way that you get a production oriented build in a staging env. I added the npm commands just to demonstrate. |
Then please provide an actual reproduction so I can consider to reopen. Please understand that we can't take your word for it and won't try to reproduce by a mere description. |
This seems to be a regression introduced in #1503 |
@LinusBorg ghost is right, there's no way to get exact production build, but with staging/test env. |
See my last comment. |
@LinusBorg this is still an issue, and the reproduction has been there since 9 Jun 2018 |
the codesandbox that is provided by OP does not use Vue CLI 3 (its an old Vue CLI 2 template), so is obviously not a valid reproduction. Other reproductions were not provided. |
Ok never mind. This issue actually seems resolved for me as I misunderstood the documentation. NODE_ENV needs to be set explicitly and it is it works, even if using "staging":"vue-cli-service build --mode staging" in package.json Edit: NODE_ENV works when the .env.staging file has no trailing # comments - see https://github.com/motdotla/dotenv#rules |
Glad you could solve your problem. |
Version
3.0.0-beta.16
Reproduction link
https://codesandbox.io/s/qlx254n09j
Steps to reproduce
.env.staging
file in the rootNODE_ENV=production
andVUE_APP_ENV=staging
in the file"staging":"vue-cli-service build --mode staging",
npm run build --mode staging
npm run staging
What is expected?
Case 1
npm run buid --mode staging
gives a production oriented build with staging variables
Case 2
npm run staging
gives a production oriented build with staging variables
What is actually happening?
Case 1
It gives a production oriented build with production variables
Case 2
It gives a development oriented build with staging variables
I need this to deploy this to Heroku. CD/CI. I'm using
postinstall
script to buildproduction
,dev
orstaging
servers based on theAPP_VUE_ENV
variable. Please help me. I'm super excited with Vue so far!Reference:
https://cli.vuejs.org/guide/mode-and-env.html#example-staging-mode
#948
https://forum.vuejs.org/t/how-to-build-production-app-with-varying-config/29708
The text was updated successfully, but these errors were encountered: