-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Explain the possible parameters when webpack.config.js exports a function #1479
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jennings thanks for this addition. Please see my comment below, I think everything you've added is perfect, we should just move it to another section of the docs.
| webpack --env.prod=1 | { prod: 1 } | | ||
| webpack --env.prod=foo | { prod: "foo" } | | ||
| webpack --env.prod --env.bar | { prod: true, bar: true } | | ||
| webpack --env.prod --env bar | [{ prod: true }, "bar"] | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The majority of this should be moved to the CLI section of the documentation, probably in this section as that's the only place I'm seeing --env
mentioned. Then, from this page, we should link to there (feel free to create a dedicated section for --env
with a header so you can link directly to it's hash).
d12cb4f
to
ccd2754
Compare
@skipjack Thanks for your help, I rebased and updated based on your suggestions, let me know if you'd like me to change anything else. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jennings added some other minor comments, once those are addressed we should be good to go.
content/api/cli.md
Outdated
@@ -129,6 +119,25 @@ webpack --json > stats.json | |||
|
|||
In every other case, webpack prints out a set of stats showing bundle, chunk and timing details. Using this option the output can be a JSON object. This response is accepted by webpack's [analyse tool](https://webpack.github.com/analyse), or chrisbateman's [webpack-visualizer](https://chrisbateman.github.io/webpack-visualizer/), or th0r's [webpack-bundle-analyzer](https://github.com/th0r/webpack-bundle-analyzer). The analyse tool will take in the JSON and provide all the details of the build in graphical form. | |||
|
|||
### Environment options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would capitalize "Options" as it's in the title.
@@ -11,21 +11,26 @@ contributors: | |||
Besides exporting a single config object, there are a few more ways that cover other needs as well. | |||
|
|||
|
|||
## Exporting a function to use `--env` | |||
## Exporting a function to use `--env` and `argv` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe simplify this title to "Exporting a Function"? Then in api/cli.md
update your link to go directly here, e.g. /configuration/configuration-types#exporting-a-function
.
One option is to export a function from your webpack config instead of exporting an object. The function will be invoked with two arguments: | ||
|
||
* An environment as the first parameter. See the [environment options CLI documentation](/api/cli#environment-options) for syntax examples. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop this line break... typically between list items we don't include them.
* Expand on how --env arguments gets translated into the env parameter. * Briefly explain the argv parameter.
ccd2754
to
363650f
Compare
@skipjack Updated:
|
@jennings thanks! Awesome work on this as well as #1489. If you're interested in contributing regularly, I would be happy to invite you to the organization. I feel like we're finally getting this repo into a good place but there is still a little ways to go with the backlog before we can fully focus on cleaning things up, reviewing the content, and organizing it all properly. Anyways any time you can spare is definitely appreciated. |
@skipjack Thanks :) I do want to contribute more. I'm not certain yet how much time I can devote to it, but, I can give it a shot. Anything specific you would want me to go after? I saw #1258, it seems like most topics in your checklist have been "claimed". I'm fairly new to webpack, but I don't mind learning something new in order to improve the docs. |
Yeah #1258 is pretty close to completion as you can see in this comment. The ones left are somewhat advanced so I don't know if that would be a good start. If you could pick up any of the miscellaneous issues though that would be great and feel free to comment on them to discuss direction, e.g. where the new content might go if it's not obvious or just general thoughts on how the issue can be resolved. |
This adds a table of possible
--env
arguments and how they translate into theenv
parameter.It also mentions the second parameter,
argv
, and gives an example of detecting if-p
or--optimize-minimize
was given.