My solution:
In quasar.conf.js:
const envparser = require('./src/envparser')
...
build: {
env: envparser(),
...
./src/envparser:
const DotEnv = require('dotenv')
const parsedEnv = DotEnv.config().parsed
const argEnv = {}
process.argv.forEach((v, k) => {
if (v.indexOf('--env.') === 0) {
argEnv[v.substring(6)] = process.argv[k + 1]
}
})
module.exports = function () {
for (let key in parsedEnv) {
if (typeof parsedEnv[key] === 'string') {
parsedEnv[key] = JSON.stringify(parsedEnv[key])
}
}
for (let key in argEnv) {
parsedEnv[key] = JSON.stringify(argEnv[key])
}
return parsedEnv
}
So now you can use .env file for define environment variables, .env.prod and .env.dev for production and development mode and those will be overwritten by console arguments:
quasar dev --env.VARIABLE "Value"