How to support multiple environments
-
I’m trying to create project with multiple environments: staging, prod, test + development obviously.
With Vuejs that’s pretty straightforwardvue-cli-service build --mode staging
And create .env.staging file.
Important note that process.env should be accessed from quasar.conf file in order to set different publicPath for each env.
How can I achieve this behavior at Quasar?
Thanks
-
-
Thanks @dobbel but I already read this.
This solution help me only for build process. How should I create .env.staging file and use it in the code? -
-
Did anyone get a solution for dev, staging and production environments ?
I had the idea of using
quasar build -d
(debug mode) as staging andquasar build
as production, each with its own dist folder, and I set a DEPLOY_MODE env variable accordingly: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') },
Then in my boot file, I use
process.env.DEPLOY_MODE
to determine which keys to use in my production env file, since quasar/dotenv extension only seems to support two environments (side note: I saw someone committed some changes on github to support staging but it was then reverted)This works, but I wondered if anyone else had a more elegant solution ?
-
@tlloyduk take a look on qenv app extension.
-
ok will do
-
@tlloyduk replying to myself here, but I am not sure qenv is vastly different to what I proposed so will stick to my original plan!