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

Add yarn rw dev option to pass any Webpack config as a string #904

Merged
merged 3 commits into from
Jul 29, 2020

Conversation

thedavidprice
Copy link
Contributor

@thedavidprice thedavidprice commented Jul 28, 2020

Fix #890

This is an alternate, mutual approach to #891 We could merge both and add to CLI docs for yarn rw dev

@peterp My approach here is to add a string option to the Yargs command, which could be used to pass any+all Webpack DevServer config options, which will override webpack.development.js.

Most importantly --> What do you this of this approach?

Secondarly --> does the code implementation pass your PeterPSniffTest™?

edit: Oh, one question. Should the name of the option be webpack-config or webpackConfig for CLI option?

Comment on lines 22 to 27
.positional('webpackConfig', {
alias: 'wpc',
description:
'Optional string of Webpack DevServer config options, e.g. `--wpc="--port=1234"`',
type: 'string',
})
Copy link
Contributor

@peterp peterp Jul 28, 2020

Choose a reason for hiding this comment

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

Ooh, I love this... This is what I've wanted for a long time.

Could we make it more generic? Cause I would like to make this also work for jest, lint, etc.

Maybe something like --forward. In yarn and npm this used to just be --: yarn test -- --watchAll, but I don't think that'll work anymore.

@thedavidprice
Copy link
Contributor Author

Yargs "Stop Parsing" Forwarder

Yargs does have an option to use -- to stop parsing and capture remainders into an array:
https://github.com/yargs/yargs/blob/master/docs/tricks.md#stop-parsing

However, when I try to run using yarn rw dev -- blahblah, it appears Yarn intercepts and throws a warning, which seems to disrupt the defaults (i.e. sides: api, web in our case):

warning From Yarn 1.0 onwards, scripts don't require "--" for options to be forwarded. In a future version, any explicit "--" will be forwarded as-is to the scripts.
...
Invalid values:
  Argument: side, Given: "blahBlahblahBlah", Choices: "api", "web"
error Command failed with exit code 1.

Bummer ☹️

@thedavidprice
Copy link
Contributor Author

@peter this is ready to merge per your approval:

  • changed the option name to forward with alias fwd
  • updated description and provided a better example of use

I'm creating a PR with CLI doc update now.

@thedavidprice
Copy link
Contributor Author

@peterp peterp merged commit 5ea8db1 into main Jul 29, 2020
@styfle
Copy link

styfle commented Jul 29, 2020

Thanks! When can we expect a new stable release?

@thedavidprice
Copy link
Contributor Author

@styfle By end of today!!

@thedavidprice thedavidprice added this to the next release milestone Jul 30, 2020
styfle added a commit to vercel/vercel that referenced this pull request Jul 30, 2020
@peterp peterp deleted the dsp-add-dev-server-options-string branch November 11, 2020 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for yarn rw dev --port 8080
3 participants