For those looking to manage multiple environments, consider exploring the @quasar/qenv
extension. It appears to provide support for this feature. Check it out at: https://github.com/quasarframework/app-extension-qenv
In my case, where I utilize Firebase Hosting for both staging and production within a single project, I adopted a different approach. I utilized quasar build -d
in debug mode for staging, and quasar build
for production. Each build generated its own respective dist
folder. Additionally, I configured a DEPLOY_MODE environment variable in quasar.conf.js
:
build: {
distDir: ctx.debug ? `dist/${ctx.modeName}-dev` : `dist/${ctx.modeName}`,
env: {
DEPLOY_MODE: ctx.prod && !ctx.debug ? 'PRODUCTION' : (ctx.prod && ctx.debug ? 'STAGING' : 'DEV')
},
...
Incorporating the dotenv
extension, I created .env.prod and .env.dev files containing keys specific to production and staging environments (e.g., API_KEY=blah, API_STAGING_KEY=blah). In my boot file, I dynamically selected the appropriate key based on the value of process.env.DEPLOY_MODE:
if(process.env.DEPLOY_MODE === 'staging') {
const API_KEY = process.env.API_STAGING_KEY
} else {
const API_KEY = process.env.API_KEY
}
While @qenv may offer a more elegant solution, the above method sufficed for my straightforward project.