Build for more environments such as staging #15065
-
I want to build for different environments other than production, for example, staging. How is this done? I did some looking around but I'm confused more than ever. With NPM it's easy, all you do is create a separate env file and add a new script in the package.json but with Quasar, I have no clue how it's done. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
What I doing for my projects is that I have separate scripts for all of needed environments, and separated https://quasar.dev/quasar-cli-webpack/handling-process-env Or, if you need more |
Beta Was this translation helpful? Give feedback.
-
What I do in my projects when I need different environments is the following: I firstly like to create a const dotenv = require('dotenv');
const files = {
...dotenv.config({ path: 'variables/.env' }).parsed,
...dotenv.config({ path: `variables/.env.${process.env.ENVIRONMENT}` }).parsed,
...dotenv.config({ path: `variables/.env.${process.env.ENVIRONMENT}.local` }).parsed,
};
module.exports = () => {
Object.keys(files, (key) => {
if (typeof files[key] !== 'string') {
files[key] = JSON.stringify(files[key]);
}
});
return files;
}; As you see, it requires In the same, I'll give you a default content of the
In my const PARSER = require('./variables/parser')();
// ...
build: {
env: PARSER
} That completes those steps, what is left is to create custom scripts for all of the environments, so in my "dev:local": "cross-env ENVIRONMENT=local quasar dev -m pwa",
"prebuild:local": "npm run lint",
"build:local": "cross-env ENVIRONMENT=local npm quasar build -m pwa --debug",
"dev:staging": "cross-env ENVIRONMENT=staging quasar dev -m pwa",
"prebuild:staging": "npm run lint",
"build:staging": "cross-env ENVIRONMENT=staging npm quasar build -m pwa --debug", I use That should be it. |
Beta Was this translation helpful? Give feedback.
What I do in my projects when I need different environments is the following:
I firstly like to create a
variables
folder in the project root, after which I create aparser.js
file with this content:As you see, it requires
dotenv
, so you n…