Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quasar: build with development mode

I have in quasar.conf.js env settings with something like this:

env: {
  API_URL: ctx.dev
    ? 'https://dev.apis.test.io/v2/'
    : 'https://apis.test.io/v2/'
}

When I run app on local host dev api is used, when I run quasar build production api is used. So that is working. How can I build with dev env settings?

For example on plain Vue yarn build --mode development works just fine. How can I do the same thing with quasar?

I tried:

quasar build --mode development

quasar build --mode dev

quasar build --development

quasar build --dev

quasar build --debug

and I always get production link in dist folder files

like image 206
Cup5y Avatar asked Sep 14 '25 21:09

Cup5y


1 Answers

the answer above is not really wrong. You can do something like this:

  1. create multiple .env files, for me best option is:

    .env.local
    .env.development
    .env.production
    
  2. inside quasar.conf.js use dotenv library:

  const env = require("dotenv").config({
path: `.env.${(process.env.ENV_FILE || process.env.NODE_ENV).toLowerCase()}`,
}).parsed;

Here i'm checking if ENV_FILE was provided and if not, using default NODE_ENV. This is done so that the standard command quasar build can pick up the required file

  1. then put vars to quasar env:
    build: {
      vueRouterMode: 'history', // available values: 'hash', 'history'
      env: {
        ...env
      },
  1. then run build for production or stage or run dev server with command:
ENV_FILE=development quasar build

For me it works like a charm, because i have more than two envs

like image 159
saike Avatar answered Sep 16 '25 14:09

saike