Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!