Skip to content

Additional .env mode #10234

Jul 29, 2021 · 1 comments · 5 replies
Discussion options

You must be logged in to vote

What I do in my projects is use dotenv package, create parser file:

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 quasar.conf.js

const parser = require('PATH_TO_PARSER_FILE');

build: {
  env: parser(),
}

Then create scripts in package.json:

 "dev:staging": "cross-env ENVIRONMENT=stagin…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@xLinley
Comment options

@xLinley
Comment options

@mohanprasathsj
Comment options

@metalsadman
Comment options

@egloeckle
Comment options

Answer selected by xLinley
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants