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
the answer above is not really wrong. You can do something like this:
create multiple .env files, for me best option is:
.env.local
.env.development
.env.production
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
build: {
vueRouterMode: 'history', // available values: 'hash', 'history'
env: {
...env
},
ENV_FILE=development quasar build
For me it works like a charm, because i have more than two envs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With