3.0.0-beta.16
https://codesandbox.io/s/qlx254n09j
.env.staging
file in the root NODE_ENV=production
and VUE_APP_ENV=staging
in the file"staging":"vue-cli-service build --mode staging",
npm run build --mode staging
npm run staging
npm run buid --mode staging
gives a production oriented build with staging variables
npm run staging
gives a production oriented build with staging variables
It gives a production oriented build with production variables
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 build production
, dev
or staging
servers based on the APP_VUE_ENV
variable. Please help me. I'm super excited with Vue so far!
https://cli.vuejs.org/guide/mode-and-env.html#example-staging-mode
https://github.com/vuejs/vue-cli/issues/948
https://forum.vuejs.org/t/how-to-build-production-app-with-varying-config/29708
This is related to how npm passes arguments to scripts when using npm run
# passes the `mode` argument to npm
npm run build --mode staging
#passes the `mode` argument to vue-cli service`
npm run build -- --mode staging
In other words: all arguments before --
are interpreted as arguments for npm itself, not the script you are running.
@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.
Most helpful comment
This is related to how npm passes arguments to scripts when using
npm run
In other words: all arguments before
--
are interpreted as arguments for npm itself, not the script you are running.