Skip to content

Enhance env flag support #1932

Closed
Closed

Description

@anshumanv

Is your feature request related to a problem? Please describe.
env flag presently supports only booleans, which is not the most verbose thing to work with plus has high migration overhead as everyone is pretty much used to the old format. So we need to support at least custom string value for properties which are passed to env, something like -

webpack --env app="test" --env title="start"

Describe the solution you'd like

We'll have to introduce separate arg parsing behaviour for env.

Describe alternatives you've considered

Additional context

Activity

  1. LBRDan commented on Oct 13, 2020

    @LBRDan

    Any chance of viewing this issue resolved anytime soon?

    I think that should be reported on your docs (as a temporary fault on this version) as it can easily drive people nuts. It is also a huge regression (not enhancement as it's marked ATM) and it is against your own docs ( https://webpack.js.org/api/cli/#environment-options )

    Please consider switch this issue type both for labels and work priority, for sake of a respectful community using your solution as a multi environment standard.

  2. alexander-akait commented on Oct 13, 2020

    @alexander-akait
    Member

    Any chance of viewing this issue resolved anytime soon?

    No, it is OSS

    Please consider switch this issue type both for labels and work priority, for sake of a respectful community using your solution as a multi environment standard.

    You can help and send a PR

  3. LBRDan commented on Oct 13, 2020

    @LBRDan

    I could for sure, but i cannot change the labels nor webpack team priority neither i have the right skills to do a PR about it (i would happy to do it if i could!)

    Anyway, as you avoid to reply to my comment section about it, I will then consider my thoughts accepted because hey... that's OSS spirt too :D

  4. alexander-akait commented on Oct 13, 2020

    @alexander-akait
    Member

    @LBRDan Because we have many issues, if you want this ASAP - send a PR

  5. captainCoolMJ commented on Oct 13, 2020

    @captainCoolMJ

    If you're looking for a quick snippet to get some env parsing back, you should be able to do something like:

    env = Object.keys(env).reduce((acc, cur) => {
        const [key, value] = cur.split('=');
        acc[key] = value || env[key];
        return acc;
      }, {});
    

    That should help to bring some of the key/value parsing back

    webpack --env production --env app="test" --env title="start"
    >>>
    {
      production: true,
      app: 'test'
      title: 'start'
    }
    

    Hope that helps!

  6. anshumanv commented on Oct 13, 2020

    @anshumanv
    ContributorAuthor

    Thanks for all the input everyone, #1939 should fix it and should land in the next release, hopefully soon :)

  7. shwetaarshad commented on Dec 17, 2020

    @shwetaarshad

    nps is executing default : nps webpack
    nps is executing webpack : nps webpack.server
    nps is executing webpack.server : webpack-dev-server -d --devtool '#source-map' --inline --env.server
    [webpack-cli] Unknown argument: #source-map
    [webpack-cli] Unknown argument: --inline
    [webpack-cli] Unknown argument: --env.server
    The script called "webpack.server" which runs "webpack-dev-server -d --devtool '#source-map' --inline --env.server" failed with exit code 2 https://github.com/sezna/nps/blob/master/other/ERRORS_AND_WARNINGS.md#failed-with-exit-code
    The script called "webpack" which runs "nps webpack.server" failed with exit code 2 https://github.com/sezna/nps/blob/master/other/ERRORS_AND_WARNINGS.md#failed-with-exit-code
    The script called "default" which runs "nps webpack" failed with exit code 2 https://github.com/sezna/nps/blob/master/other/ERRORS_AND_WARNINGS.md#failed-with-exit-code
    npm ERR! code ELIFECYCLE
    npm ERR! errno 2

  8. shwetaarshad commented on Dec 17, 2020

    @shwetaarshad

    How can I resolve above with below webpack packages:

    "webpack": "^5.11.0",
    "webpack-cli": "^4.2.0",
    "webpack-dev-server": "^4.0.0-beta.0",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions