mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
[@types/copy-webpack-plugin] Update to v5.0 of copy-webpack-plugin (#34880)
* ADD: 'test' option and relavant documentation to CopyPattern * Update types to copy-webpack-plugin version 5 * Update header * Update header
This commit is contained in:
parent
5746d0876f
commit
c96320313a
@ -63,10 +63,22 @@ const c: Configuration = {
|
||||
// Copy glob results (without dot files) to {output}/to/directory/
|
||||
{
|
||||
from: '**/*.png',
|
||||
fromArgs: { dot: false },
|
||||
to: 'to/directory'
|
||||
},
|
||||
|
||||
// Turns 1st and 2nd level directory names into file name seperated by a dash for png files
|
||||
{
|
||||
from: '*/*',
|
||||
to: '[1]-[2].[hash].[ext]',
|
||||
test: /([^/]+)\/(.+)\.png$/,
|
||||
},
|
||||
], {
|
||||
// Log only errors
|
||||
logLevel: 'error',
|
||||
|
||||
// All 'from' paths will be intepreted from this context
|
||||
context: 'app/',
|
||||
|
||||
ignore: [
|
||||
// Doesn't copy any files with a txt extension
|
||||
'*.txt',
|
||||
|
||||
76
types/copy-webpack-plugin/index.d.ts
vendored
76
types/copy-webpack-plugin/index.d.ts
vendored
@ -1,12 +1,13 @@
|
||||
// Type definitions for copy-webpack-plugin 4.4
|
||||
// Type definitions for copy-webpack-plugin 5.0
|
||||
// Project: https://github.com/webpack-contrib/copy-webpack-plugin
|
||||
// Definitions by: flying-sheep <https://github.com/flying-sheep>
|
||||
// Definitions by: flying-sheep <https://github.com/flying-sheep>
|
||||
// avin-kavish <https://github.com/avin-kavish>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="node"/>
|
||||
|
||||
import { Plugin } from 'webpack'
|
||||
import { Plugin, compiler } from 'webpack'
|
||||
import { IOptions } from 'minimatch'
|
||||
|
||||
interface MiniMatchGlob extends IOptions {
|
||||
@ -20,46 +21,69 @@ interface MiniMatchOptions extends IOptions {
|
||||
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.
|
||||
* resolved glob path if `from` is glob.
|
||||
*/
|
||||
to?: string
|
||||
/**
|
||||
* How to interpret `to`. defaults:
|
||||
* 'file' if to has extension or from is file.
|
||||
* 'dir' if from is directory, to has no extension or ends in '/'.
|
||||
* 'template' if to contains a template pattern.
|
||||
*/
|
||||
toType?: 'file' | 'dir' | 'template'
|
||||
/** A path that determines how to interpret the `from` path. (default: `compiler.options.context`) */
|
||||
/** A path that determines how to interpret the `from` path.
|
||||
*
|
||||
* (default: `options.context | compiler.options.context`)
|
||||
* */
|
||||
context?: string
|
||||
/**
|
||||
* Removes all directory references and only copies file names.
|
||||
*
|
||||
* If files have the same name, the result is non-deterministic. (default: `false`)
|
||||
* How to interpret `to`. default: undefined
|
||||
*
|
||||
* `file` - if 'to' has extension or 'from' is file.
|
||||
* `dir` - if 'from' is directory, 'to' has no extension or ends in '/'.
|
||||
* `template` - if 'to' contains a template pattern.
|
||||
*/
|
||||
flatten?: boolean
|
||||
/** Additional globs to ignore for this pattern. (default: `[]`) */
|
||||
ignore?: Array<string | MiniMatchGlob>
|
||||
/** Function that modifies file contents before writing to webpack. (default: `(content, path) => content`) */
|
||||
transform?: (content: Buffer, path: string) => string | Buffer
|
||||
/** Enable transform caching. You can use `{ cache: { key: 'my-cache-key' } }` to invalidate the cache. (default: `false`) */
|
||||
cache?: boolean | { key: string }
|
||||
toType?: 'file' | 'dir' | 'template'
|
||||
/**
|
||||
* Pattern for extracting elements to be used in `to` templates.
|
||||
*
|
||||
* Defines a `RegExp` to match some parts of the file path. These capture groups can be reused in the name property using [N]
|
||||
* placeholder. Note that [0] will be replaced by the entire path of the file, whereas [1] will contain the first capturing
|
||||
* parenthesis of your RegExp and so on...
|
||||
*
|
||||
* */
|
||||
test?: RegExp
|
||||
/** Overwrites files already in `compilation.assets` (usually added by other plugins; default: `false`) */
|
||||
force?: boolean
|
||||
/** Additional globs to ignore for this pattern. (default: `[]`) */
|
||||
ignore?: Array<string | MiniMatchGlob>
|
||||
/**
|
||||
* Removes all directory references and only copies file names. (default: `false`)
|
||||
*
|
||||
* If files have the same name, the result is non-deterministic.
|
||||
*/
|
||||
flatten?: boolean
|
||||
/** Function that modifies file contents before writing to webpack. (default: `(content, path) => content`) */
|
||||
transform?: (content: Buffer, path: string) => string | Buffer | Promise<string | Buffer>
|
||||
/**
|
||||
* Enable transform caching. (default: `false`)
|
||||
*
|
||||
* You can use `{ key: 'my-cache-key' }` to invalidate the cache.
|
||||
* */
|
||||
cache?: boolean | { key: string }
|
||||
/**
|
||||
* Allows to modify the writing path.
|
||||
*
|
||||
* Returns the new path or a promise that resolves into the new path
|
||||
*/
|
||||
transformPath?: (targetPath: string, absolutePath: string) => string | Promise<string>
|
||||
}
|
||||
|
||||
interface CopyWebpackPluginConfiguration {
|
||||
/** Array of globs to ignore. (applied to from; default: `[]`) */
|
||||
/** Level of messages that the module will log. (default: `'warn'`) */
|
||||
logLevel?: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent'
|
||||
/** Array of globs to ignore. (applied to `from`; default: `[]`) */
|
||||
ignore?: Array<string | MiniMatchGlob>
|
||||
/** A path that determines how to interpret the from path, shared for all patterns. default: `'compiler.options.context'` */
|
||||
context?: string
|
||||
/** Copies files, regardless of modification when using `watch` or `webpack-dev-server`. All files are copied on first build, regardless of this option. (default: `false`) */
|
||||
copyUnmodified?: boolean
|
||||
/** Debug level. warning: only warnings, info/true: file location and read info, debug: very detailed debugging info. (default: `'warning'`) */
|
||||
debug?: 'warning' | 'info'|true | 'debug'
|
||||
}
|
||||
|
||||
interface CopyWebpackPlugin {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user