Additional .env mode #10234
-
Hi, Right now when i launch the command "quasar dev" the .env file gets chosen and when i run "quasar build" the .env.production file gets chosen; this is all done automatically. How can i configure a third file (.env.staging), and how can i run in dev and build the dist using this .env.staging file? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
What I do in my projects is use const dotenv = require("dotenv");
const files = {
...dotenv.config({ path: "./.env" }).parsed,
...dotenv.config({ path: `./.env.${process.env.ENVIRONMENT}` }).parsed,
...dotenv.config({ path: `./.env.${process.env.ENVIRONMENT}.local` }).parsed
};
module.exports = function () {
for (key in files) {
if (typeof files[key] !== "string") {
files[key] = JSON.stringify(files[key]);
}
}
return files;
}; Then import that parser into const parser = require('PATH_TO_PARSER_FILE');
build: {
env: parser(),
} Then create scripts in "dev:staging": "cross-env ENVIRONMENT=staging quasar dev",
"prebuild:staging": "npm run lint",
"build:staging": "cross-env ENVIRONMENT=staging quasar build", And, finally, create Do keep in mind this is for Quasar v1. |
Beta Was this translation helpful? Give feedback.
What I do in my projects is use
dotenv
package, create parser file:Then import that parser into
quasar.conf.js
Then create scripts in
package.json
: