'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
Solution 1:[1]
try run MY_API=api.com quasar build
Solution 2:[2]
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
usedotenv
library:
const env = require('dotenv').config({ path: `.env.${process.env.ENV_FILE.toLowerCase()}` }).parsed
- then put vars to quasar env:
build: {
vueRouterMode: 'history', // available values: 'hash', 'history'
env: {
...env
},
- 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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | saike |