diff --git a/types/copy-webpack-plugin/copy-webpack-plugin-tests.ts b/types/copy-webpack-plugin/copy-webpack-plugin-tests.ts index b58b242fc2..9a1331a502 100644 --- a/types/copy-webpack-plugin/copy-webpack-plugin-tests.ts +++ b/types/copy-webpack-plugin/copy-webpack-plugin-tests.ts @@ -51,6 +51,21 @@ const c: Configuration = { to: 'directory/with/extension.ext', toType: 'dir' }, + + // transform and cache (cache is always used with transform option). + { + from: 'src/*.png', + to: 'dest/', + transform: (content, path) => content, + cache: true + }, + + // Copy glob results (without dot files) to {output}/to/directory/ + { + from: '**/*.png', + fromArgs: { dot: false }, + to: 'to/directory' + }, ], { ignore: [ // Doesn't copy any files with a txt extension diff --git a/types/copy-webpack-plugin/index.d.ts b/types/copy-webpack-plugin/index.d.ts index 8bfae1e0ed..35150a5e72 100644 --- a/types/copy-webpack-plugin/index.d.ts +++ b/types/copy-webpack-plugin/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for copy-webpack-plugin v4.0.0 +// Type definitions for copy-webpack-plugin v4.4.1 // Project: https://github.com/kevlened/copy-webpack-plugin // Definitions by: flying-sheep // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -10,9 +10,15 @@ interface MiniMatchGlob extends IOptions { glob: string } +interface MiniMatchOptions extends IOptions { + cwd?: string +} + interface CopyPattern { /** File source path or glob */ from: string | MiniMatchGlob + /** See the `node-glob` options in addition to the ones below. (default: `{ cwd: context }`) */ + fromArgs?: MiniMatchOptions /** * Path or webpack file-loader patterns. defaults: * output root if `from` is file or dir. @@ -38,6 +44,8 @@ interface CopyPattern { ignore?: Array /** Function that modifies file contents before writing to webpack. (default: `(content, path) => content`) */ transform?: (content: string, path: string) => string + /** Enable transform caching. You can use `{ cache: { key: 'my-cache-key' } }` to invalidate the cache. (default: `false`) */ + cache?: boolean | { key: string } /** Overwrites files already in `compilation.assets` (usually added by other plugins; default: `false`) */ force?: boolean }