Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
Vue.js environment variables without vue-cli

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?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

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

about 4 years ago · Juan Pablo Isaza Denunciar

0

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

First install the dotenv package and then use this on my webpack.config.js:

const dotenv = require('dotenv');

.configureDefinePlugin(options => {
    const dotenvOptions = {};
    const envConfigPath = `.env.${process.env.NODE_ENV}`;

    if (fs.existsSync(envConfigPath)) dotenvOptions.path = envConfigPath;

    const env = dotenv.config(dotenvOptions);

    if (env.error) {
        throw env.error;
    }

    options['process.env'].PMP_API_BASE_URI = JSON.stringify(env.parsed.PMP_API_BASE_URI);
})

If .env.dev.local is needed then provide NODE_ENV=dev.local while running npm run build command.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda