You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,6 +87,7 @@ module.exports = {
87
87
|[`force`](#force)|`{Boolean}`|`false`| Overwrites files already in `compilation.assets` (usually added by other plugins/loaders). |
88
88
|[`priority`](#priority)|`{Number}`|`0`| Allows you to specify the copy priority. |
89
89
|[`transform`](#transform)|`{Object}`|`undefined`| Allows to modify the file contents. Enable `transform` caching. You can use `{ transform: {cache: { key: 'my-cache-key' }} }` to invalidate the cache. |
90
+
|[`transformAll`](#transformAll)|`{Function}`|`undefined`| Allows you to modify the contents of multiple files and save the result to one file. |
90
91
|[`noErrorOnMissing`](#noerroronmissing)|`{Boolean}`|`false`| Doesn't generate an error on missing file(s). |
91
92
|[`info`](#info)|`{Object\|Function}`|`undefined`| Allows to add assets info. |
92
93
@@ -730,6 +731,45 @@ module.exports = {
730
731
};
731
732
```
732
733
734
+
#### `transformAll`
735
+
736
+
Type: `Function`
737
+
Default: `undefined`
738
+
739
+
Allows you to modify the contents of multiple files and save the result to one file.
740
+
741
+
> ℹ️ The `to` option must be specified and point to a file. It is allowed to use only `[contenthash]` and `[fullhash]` template strings.
742
+
743
+
**webpack.config.js**
744
+
745
+
```js
746
+
module.exports= {
747
+
plugins: [
748
+
newCopyPlugin({
749
+
patterns: [
750
+
{
751
+
from:"src/**/*.txt",
752
+
to:"dest/file.txt",
753
+
// The `assets` argument is an assets array for the pattern.from ("src/**/*.txt")
// The asset content can be obtained from `asset.source` using `source` method.
757
+
// The asset content is a [`Buffer`](https://nodejs.org/api/buffer.html) object, it could be converted to a `String` to be processed using `content.toString()`
0 commit comments