Skip to content

Commit 65314cd

Browse files
adgllorentemichael-ciniawsky
authored andcommitted
docs(README): clarify async usage (pattern.transform) (#242)
1 parent 2a1124d commit 65314cd

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Or, in case of just a `from` with the default destination, you can also use a `{
5959
|[`force`](#force)|`{Boolean}`|`false`|Overwrites files already in `compilation.assets` (usually added by other plugins/loaders)|
6060
|[`ignore`](#ignore)|`{Array}`|`[]`|Globs to ignore for this pattern|
6161
|`flatten`|`{Boolean}`|`false`|Removes all directory references and only copies file names.⚠️ If files have the same name, the result is non-deterministic|
62-
|[`transform`](#transform)|`{Function}`|`(content, path) => content`|Function that modifies file contents before copying|
62+
|[`transform`](#transform)|`{Function\|Promise}`|`(content, path) => content`|Function or Promise that modifies file contents before copying|
6363
|[`cache`](#cache)|`{Boolean\|Object}`|`false`|Enable `transform` caching. You can use `{ cache: { key: 'my-cache-key' } }` to invalidate the cache|
6464
|[`context`](#context)|`{String}`|`options.context \|\| compiler.options.context`|A path that determines how to interpret the `from` path|
6565

@@ -200,6 +200,8 @@ and so on...
200200

201201
### `transform`
202202

203+
#### `{Function}`
204+
203205
**webpack.config.js**
204206
```js
205207
[
@@ -215,6 +217,23 @@ and so on...
215217
]
216218
```
217219

220+
#### `{Promise}`
221+
222+
**webpack.config.js**
223+
```js
224+
[
225+
new CopyWebpackPlugin([
226+
{
227+
from: 'src/*.png',
228+
to: 'dest/',
229+
transform (content, path) {
230+
return Promise.resolve(optimize(content))
231+
}
232+
}
233+
], options)
234+
]
235+
```
236+
218237
### `cache`
219238

220239
**webpack.config.js**

0 commit comments

Comments
 (0)