[Vuejs]-VueJs Environment Variables Priority

0👍

if you look at the example in the docs, you’ll see that both these files are dependent on the mode, so if you run this command:

vue-cli-service build --mode development

it will use .env.development and if you run:

vue-cli-service serve --mode development

it should use .env.development.local

but you can also use .env.local which will always be loaded when you run locally, even without defining the mode.

So to summarize:

  1. on remote dev, run the command: vue-cli-service build --mode development and .env.development will be loaded
  2. on local env, run: vue-cli-service serve --mode development or change .env.development.local to .env.local

0👍

local ENV files should not be committed into the repo. Only thing which makes them local is the fact, that default .gitignore file is set to ignore them. If you commit them into the repo, it will be loaded on your remote dev server (takes priority over .env.development)

Leave a comment