Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance env flag support #1932

Closed
anshumanv opened this issue Oct 12, 2020 · 8 comments · Fixed by #1939
Closed

Enhance env flag support #1932

anshumanv opened this issue Oct 12, 2020 · 8 comments · Fixed by #1939

Comments

@anshumanv
Copy link
Member

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

@LBRDan
Copy link

LBRDan commented Oct 13, 2020

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.

@alexander-akait
Copy link
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

@LBRDan
Copy link

LBRDan commented Oct 13, 2020

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

@alexander-akait
Copy link
Member

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

@captainCoolMJ
Copy link

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!

@anshumanv
Copy link
Member Author

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

@shwetaarshad
Copy link

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

@shwetaarshad
Copy link

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants