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
+40
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.
2
Has conversations. Original line has conversations.
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()`
@@ -88,7 +88,7 @@ exports[`validate options should throw an error on the "patterns" option with "[
88
88
exports[`validate options should throw an error on the "patterns" option with "[{"from":"test.txt","to":"dir","context":"context","transform":true}]" value 1`] =`
89
89
"Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
@@ -98,6 +98,11 @@ exports[`validate options should throw an error on the "patterns" option with "[
98
98
object { transformer?, cache? }"
99
99
`;
100
100
101
+
exports[`validate options should throw an error on the "patterns" option with "[{"from":"test.txt","to":"dir","context":"context","transformAll":true}]" value 1`] =`
102
+
"Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
103
+
- options.patterns[0].transformAll should be an instance of function."
104
+
`;
105
+
101
106
exports[`validate options should throw an error on the "patterns" option with "[{"from":"test.txt","to":"dir","context":true}]" value 1`] =`
102
107
"Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
103
108
- options.patterns[0].context should be a string."
@@ -121,7 +126,7 @@ exports[`validate options should throw an error on the "patterns" option with "[
121
126
exports[`validate options should throw an error on the "patterns" option with "[{"from":"test.txt","to":true,"context":"context"}]" value 1`] =`
122
127
"Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.