Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

170
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda