What I've done so far:
I've been trying to setup multiple build modes like staging
, testing
, production
and development
based on NODE_ENV=production
. So I'm keeping the respective files in the root of the project folder like:
- .env.production
- .env.staging
- .env.testing
- .env.development
Now, all these files are having
NODE_ENV=production
VUE_APP_ENV=<mode>
The document that I followed clearly states that,
vue-cli-service build --mode staging
builds a production app in staging mode, using .env, .env.staging and .env.staging.local if they are present.
Problem:
As expected, running the command npm run build --mode staging
is to give a production build with variable as listed in the .env.staging
file. However, production
variables are loaded instead of staging
.
Ref: