Skip to content

How we should work with different enviroments? #824

@maxim-usikov

Description

@maxim-usikov

What problem does this feature solve?

More clearest way to work with different enviroments.

What does the proposed API look like?

I think we need only one .env file, that contain all kind of enviroment variables.
That file should not be tracked by VCS.
But we can have documented .env.example.

I mean build script should load variables only from one .env
NOT merging .env.local with .env.whatever
NOT loading multiple .env
JUST load .env and build

For CI, dev, stage, ..., or every other enviroment, you should preconfigure .env, thats all.
Dont need magic mode for vue-cli-service build --mode=internal.
vue-cli-service build should see .env and just build.

Should use dotenv.

The process for any kind of enviroment setup:

  1. pull (vcs)
  2. configure(.env)
  3. build(vue-cli-service build)
# Usage:
# bash
vue-cli-service build
APP_ENV=/full/custom/path/to/your/env/vars vue-cli-service build
vue-cli-service build --env=/full/custom/path/to/your/env/vars 
// Possible implementation
const args = require('yargs').argv
require('dotenv').config({path: process.env.APP_ENV || process.args.env || '.env'})
// Usage:
// package.json
{
    "scripts": {
        "build": "vue-cli-service build",
        "build:first_variant": "vue-cli-service build --env=/full/custom/path/to/your/env/vars",
        "build:second_variant": "ENV_PATH=/full/custom/path/to/your/env/vars vue-cli-service build",
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions