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

refactor: tests #393

Merged
merged 1 commit into from Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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