Skip to content

Commit

Permalink
refactor: tests (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Jul 19, 2019
1 parent 7f08be6 commit ff0c736
Show file tree
Hide file tree
Showing 5 changed files with 487 additions and 401 deletions.
36 changes: 18 additions & 18 deletions README.md
Expand Up @@ -68,8 +68,8 @@ module.exports = {
| [`force`](#force) | `{Boolean}` | `false` | Overwrites files already in `compilation.assets` (usually added by other plugins/loaders). |
| [`ignore`](#ignore) | `{Array}` | `[]` | Globs to ignore files. |
| [`flatten`](#flatten) | `{Boolean}` | `false` | Removes all directory references and only copies file names. |
| [`transform`](#transform) | `{Function\|Promise}` | `undefined` | Allows to modify the file contents. |
| [`cache`](#cache) | `{Boolean\|Object}` | `false` | Enable `transform` caching. You can use `{ cache: { key: 'my-cache-key' } }` to invalidate the cache. |
| [`transform`](#transform) | `{Function\|Promise}` | `undefined` | Allows to modify the file contents. |
| [`transformPath`](#transformPath) | `{Function\|Promise}` | `undefined` | Allows to modify the writing path. |

#### `from`
Expand Down Expand Up @@ -324,14 +324,13 @@ module.exports = {
};
```

#### `transform`

Type: `Function|Promise`
Default: `undefined`
#### `cache`

Allows to modify the file contents.
Type: `Boolean|Object`
Default: `false`

##### `{Function}`
Enable/disable `transform` caching. You can use `{ cache: { key: 'my-cache-key' } }` to invalidate the cache.
Default path to cache directory: `node_modules/.cache/copy-webpack-plugin`.

**webpack.config.js**

Expand All @@ -345,13 +344,21 @@ module.exports = {
transform(content, path) {
return optimize(content);
},
cache: true,
},
]),
],
};
```

##### `{Promise}`
#### `transform`

Type: `Function|Promise`
Default: `undefined`

Allows to modify the file contents.

##### `{Function}`

**webpack.config.js**

Expand All @@ -363,21 +370,15 @@ module.exports = {
from: 'src/*.png',
to: 'dest/',
transform(content, path) {
return Promise.resolve(optimize(content));
return optimize(content);
},
},
]),
],
};
```

#### `cache`

Type: `Boolean|Object`
Default: `false`

Enable/disable `transform` caching. You can use `{ cache: { key: 'my-cache-key' } }` to invalidate the cache.
Default path to cache directory: `node_modules/.cache/copy-webpack-plugin`.
##### `{Promise}`

**webpack.config.js**

Expand All @@ -389,9 +390,8 @@ module.exports = {
from: 'src/*.png',
to: 'dest/',
transform(content, path) {
return optimize(content);
return Promise.resolve(optimize(content));
},
cache: true,
},
]),
],
Expand Down

0 comments on commit ff0c736

Please sign in to comment.