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

fix: supply argv to config with functions #1721

Merged
merged 5 commits into from
Aug 1, 2020

Conversation

anshumanv
Copy link
Member

@anshumanv anshumanv commented Aug 1, 2020

What kind of change does this PR introduce?

fix

Did you add tests for your changes?
Yes

If relevant, did you update the documentation?
NA

Summary

  • Pass argv to config function

Does this PR introduce a breaking change?
No

Other information
Fixes #1704
Fixes #1126

@anshumanv anshumanv requested a review from a team as a code owner August 1, 2020 12:10
alexander-akait
alexander-akait previously approved these changes Aug 1, 2020
Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

@webpack-bot
Copy link

@anshumanv Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@evilebottnawi Please review the new changes.

@anshumanv anshumanv merged commit 2f05940 into webpack:next Aug 1, 2020
@anshumanv anshumanv deleted the config-argv branch August 1, 2020 17:07
@milizhang
Copy link

I think this does not actually work - while it seems like the arguments now can be passed to config function, when you actually tries to pass custom arguments, user will stuck at "Which flags do you want to use", likely as the custom argument is unknown to the cli.

@anshumanv
Copy link
Member Author

@milizhang can you give example?

@milizhang
Copy link

@anshumanv Please take a look at this: https://github.com/milizhang/webpack-cli-4-argv-repro

If you use webpack-cli 3, console.log(argv.testArg); will give you "Test" if you run webpack --testArg=Test, while webpack-cli 4 will stuck asking you to clarify which argument you want to place. (Unless it is an argument that already exists in core webpack).

@anshumanv
Copy link
Member Author

Yep unknown arguments are not registered, you should use --env for it

@milizhang
Copy link

Is this something that webpack-cli explicitly decided to deprecate in V4? Are there anyway to register custom arguments in configurations?

@anshumanv
Copy link
Member Author

Is this something that webpack-cli explicitly decided to deprecate in V4? Are there anyway to register custom arguments in configurations?

Yes, passing arbitrary values was deprecated. You should be able to achieve it using --env or does it not fit your use case?

You can just do -

--env testArg=test

env = { testArg: 'test' } // in config 

@milizhang
Copy link

milizhang commented Oct 20, 2020

Got it. Picking custom argv over env was more of a preference issue. Since it is deprecated I will move toward env.

Thanks for the info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants