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

docs(README): clarify async usage (pattern.transform) #242

Merged
merged 2 commits into from
Mar 20, 2018

Conversation

adgllorente
Copy link
Contributor

@adgllorente adgllorente commented Mar 20, 2018

Issues

Edit transform documentation to specify that a Promise may be returned.

@jsf-clabot
Copy link

jsf-clabot commented Mar 20, 2018

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@michael-ciniawsky michael-ciniawsky left a 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.|
Copy link
Member

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|

Copy link
Member

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)
+ ]

@michael-ciniawsky michael-ciniawsky added this to the 4.5.1 milestone Mar 20, 2018
@michael-ciniawsky michael-ciniawsky changed the title docs(README): edit transform documentation to include promises (#160) docs(README): clarify {Promise} usage (pattern.transform) (#160) Mar 20, 2018
Copy link
Member

@michael-ciniawsky michael-ciniawsky left a comment

Choose a reason for hiding this comment

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

@michael-ciniawsky michael-ciniawsky merged commit 65314cd into webpack-contrib:master Mar 20, 2018
@michael-ciniawsky michael-ciniawsky changed the title docs(README): clarify {Promise} usage (pattern.transform) (#160) docs(README): clarify async usage (pattern.transform) Mar 20, 2018
@michael-ciniawsky michael-ciniawsky removed this from the 4.5.2 milestone May 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants