Home > other >  Vue.js environment variables without vue-cli
Vue.js environment variables without vue-cli

Time:01-31

What is the best way to load environment variables for Vue.js app without using vue-cli? In vue-cli way you just update the .env files and those variables should be available in Vue.js app like this: https://cli.vuejs.org/guide/mode-and-env.html#example-staging-mode

I am using Symfony Webpack Encore and have no vue-cli installed, how could I pass my environment variables into entire Vue application?

CodePudding user response:

Currently this looks like a decent way to load the configs: https://github.com/symfony/webpack-encore/issues/567

CodePudding user response:

just create a .env file and create you variable like this VUE_APP_XXXXX

you notice the VUE_APP make sure all variable has the VUE_APP prefix like.

VUE_APP_API_URL

for development .env.development.

for production .env.production

  •  Tags:  
  • Related