Skip to content

Add support for overriding the environment variables regex #5338

Open
@tahpot

Description

@tahpot

What problem does this feature solve?

At the moment, only environment variables prefixed with VUE_APP_ are loaded into process.env.

I have a third party library that configures itself using environment variables, however those variables can't load as they aren't Vue.js specific.

What does the proposed API look like?

I can work around the issue in vue.config.js:

module.exports = {
    configureWebpack: config => {
        const prefixRE = /^VERIDA_/;
        Object.keys(process.env).forEach(key => {
            if (prefixRE.test(key)) {
                config.plugins[1].definitions['process.env'][key] = JSON.stringify(process.env[key]);
            }
        });
    }
}

This is a huge hack however. I'm suggesting a new configuration option be added to @vue/cli-service/lib/util/resolveClientEnv.js, so that it's possible to provide a custom regex that defines the environment variables that should be made available to Vue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions