-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
docs(README): clarify async usage (pattern.transform
)
#242
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.
@adgllorente Thx in advance :)
README.md
Outdated
@@ -59,7 +59,7 @@ Or, in case of just a `from` with the default destination, you can also use a `{ | |||
|[`force`](#force)|`{Boolean}`|`false`|Overwrites files already in `compilation.assets` (usually added by other plugins/loaders)| | |||
|[`ignore`](#ignore)|`{Array}`|`[]`|Globs to ignore for this pattern| | |||
|`flatten`|`{Boolean}`|`false`|Removes all directory references and only copies file names.⚠️ If files have the same name, the result is non-deterministic| | |||
|[`transform`](#transform)|`{Function}`|`(content, path) => content`|Function that modifies file contents before copying| | |||
|[`transform`](#transform)|`{Function}`|`(content, path) => content`|Function that modifies file contents before copying. This function may return a Promise too.| |
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.
|[`transform`](#transform)|`{Function\|Promise}`|`(content, path) => content`|Function or Promise that modifies file contents before copying|
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.
Adding an example for {Promise}
would be highly appreciated (~L201+), but not mandatory :)
### `transform`
+ #### `{Function}`
**webpack.config.js**
```js
[
new CopyWebpackPlugin([
{
from: 'src/*.png',
to: 'dest/',
transform (content, path) {
return optimize(content)
}
}
], options)
]
+ #### `{Promise}`
+ **webpack.config.js**
+ ```js
+ [
+ new CopyWebpackPlugin([
+ {
+ from: 'src/*.png',
+ to: 'dest/',
+ transform (content, path) {
+ return Promise.resolve(optimize(content))
+ }
+ }
+ ], options)
+ ]
{Promise}
usage (pattern.transform
) (#160)
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.
@adgllorente Thx
{Promise}
usage (pattern.transform
) (#160)pattern.transform
)
Issues
Edit transform documentation to specify that a Promise may be returned.