-
-
Notifications
You must be signed in to change notification settings - Fork 285
docs(readme): added types #660
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
Changes from 4 commits
2059c80
e4d02ac
337e73a
bc5da1a
110ffe1
e74a3d9
6bd3ae4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -52,10 +52,8 @@ module.exports = { | |||||||||||||||||
|
||||||||||||||||||
## Options | ||||||||||||||||||
|
||||||||||||||||||
| Name | Type | Description | | ||||||||||||||||||
| :-------------------------: | :-----------------------: | :--------------------------------------- | | ||||||||||||||||||
| **[`patterns`](#patterns)** | `{Array<String\|Object>}` | Specify file related patterns for plugin | | ||||||||||||||||||
| **[`options`](#options-1)** | `{Object}` | Specify options for plugin | | ||||||||||||||||||
- **[`patterns`](#patterns)** | ||||||||||||||||||
- **[`options`](#options-1)** | ||||||||||||||||||
|
||||||||||||||||||
The plugin's signature: | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -79,26 +77,29 @@ module.exports = { | |||||||||||||||||
}; | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
### Patterns | ||||||||||||||||||
|
||||||||||||||||||
| Name | Type | Default | Description | | ||||||||||||||||||
| :-------------------------------------: | :------------------: | :---------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------- | | ||||||||||||||||||
| [`from`](#from) | `{String}` | `undefined` | Glob or path from where we copy files. | | ||||||||||||||||||
| [`to`](#to) | `{String\|Function}` | `compiler.options.output` | Output path. | | ||||||||||||||||||
| [`context`](#context) | `{String}` | `options.context \|\| compiler.options.context` | A path that determines how to interpret the `from` path. | | ||||||||||||||||||
| [`globOptions`](#globoptions) | `{Object}` | `undefined` | [Options][glob-options] passed to the glob pattern matching library including `ignore` option. | | ||||||||||||||||||
| [`filter`](#filter) | `{Function}` | `undefined` | Allows to filter copied assets. | | ||||||||||||||||||
| [`toType`](#totype) | `{String}` | `undefined` | Determinate what is `to` option - directory, file or template. | | ||||||||||||||||||
| [`force`](#force) | `{Boolean}` | `false` | Overwrites files already in `compilation.assets` (usually added by other plugins/loaders). | | ||||||||||||||||||
| [`priority`](#priority) | `{Number}` | `0` | Allows you to specify the copy priority. | | ||||||||||||||||||
| [`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. | | ||||||||||||||||||
| [`transformAll`](#transformAll) | `{Function}` | `undefined` | Allows you to modify the contents of multiple files and save the result to one file. | | ||||||||||||||||||
| [`noErrorOnMissing`](#noerroronmissing) | `{Boolean}` | `false` | Doesn't generate an error on missing file(s). | | ||||||||||||||||||
| [`info`](#info) | `{Object\|Function}` | `undefined` | Allows to add assets info. | | ||||||||||||||||||
### `Patterns` | ||||||||||||||||||
|
||||||||||||||||||
- [`from`](#from) | ||||||||||||||||||
- [`to`](#to) | ||||||||||||||||||
- [`context`](#context) | ||||||||||||||||||
- [`globOptions`](#globoptions) | ||||||||||||||||||
- [`filter`](#filter) | ||||||||||||||||||
- [`toType`](#totype) | ||||||||||||||||||
- [`force`](#force) | ||||||||||||||||||
- [`priority`](#priority) | ||||||||||||||||||
- [`transform`](#transform) | ||||||||||||||||||
- [`transformAll`](#transformAll) | ||||||||||||||||||
- [`noErrorOnMissing`](#noerroronmissing) | ||||||||||||||||||
- [`info`](#info) | ||||||||||||||||||
|
||||||||||||||||||
#### `from` | ||||||||||||||||||
|
||||||||||||||||||
Type: `String` | ||||||||||||||||||
Type: | ||||||||||||||||||
|
||||||||||||||||||
```ts | ||||||||||||||||||
type from = string; | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
Default: `undefined` | ||||||||||||||||||
|
||||||||||||||||||
Glob or path from where we copy files. | ||||||||||||||||||
|
@@ -179,10 +180,17 @@ More [`examples`](#examples) | |||||||||||||||||
|
||||||||||||||||||
#### `to` | ||||||||||||||||||
|
||||||||||||||||||
Type: `String|Function` | ||||||||||||||||||
Type: | ||||||||||||||||||
|
||||||||||||||||||
```ts | ||||||||||||||||||
type to = | ||||||||||||||||||
| string | ||||||||||||||||||
| ((pathData: { context: string; absoluteFilename?: string }) => string); | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
Default: `compiler.options.output` | ||||||||||||||||||
|
||||||||||||||||||
##### String | ||||||||||||||||||
##### `string` | ||||||||||||||||||
|
||||||||||||||||||
Output path. | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -215,7 +223,7 @@ module.exports = { | |||||||||||||||||
}; | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
##### Function | ||||||||||||||||||
##### `function` | ||||||||||||||||||
|
||||||||||||||||||
Allows to modify the writing path. | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -263,7 +271,12 @@ module.exports = { | |||||||||||||||||
|
||||||||||||||||||
#### `context` | ||||||||||||||||||
|
||||||||||||||||||
Type: `String` | ||||||||||||||||||
Type: | ||||||||||||||||||
|
||||||||||||||||||
```ts | ||||||||||||||||||
type context = string; | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
Default: `options.context|compiler.options.context` | ||||||||||||||||||
|
||||||||||||||||||
A path that determines how to interpret the `from` path. | ||||||||||||||||||
|
@@ -306,7 +319,12 @@ More [`examples`](#examples) | |||||||||||||||||
|
||||||||||||||||||
#### `globOptions` | ||||||||||||||||||
|
||||||||||||||||||
Type: `Object` | ||||||||||||||||||
Type: | ||||||||||||||||||
|
||||||||||||||||||
```ts | ||||||||||||||||||
type globOptions = object; | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
Default: `undefined` | ||||||||||||||||||
|
||||||||||||||||||
Allows to configure the glob pattern matching library used by the plugin. [See the list of supported options][glob-options] | ||||||||||||||||||
|
@@ -335,7 +353,12 @@ module.exports = { | |||||||||||||||||
|
||||||||||||||||||
#### `filter` | ||||||||||||||||||
|
||||||||||||||||||
Type: `Function` | ||||||||||||||||||
Type: | ||||||||||||||||||
|
||||||||||||||||||
```ts | ||||||||||||||||||
type filter = (filepath: string) => any; | ||||||||||||||||||
harish-sethuraman marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
Default: `undefined` | ||||||||||||||||||
|
||||||||||||||||||
> ℹ️ To ignore files by path please use the [`globOptions.ignore`](#globoptions) option. | ||||||||||||||||||
|
@@ -370,19 +393,24 @@ module.exports = { | |||||||||||||||||
|
||||||||||||||||||
#### `toType` | ||||||||||||||||||
|
||||||||||||||||||
Type: `String` | ||||||||||||||||||
Type: | ||||||||||||||||||
|
||||||||||||||||||
```ts | ||||||||||||||||||
type toType = string; | ||||||||||||||||||
harish-sethuraman marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
Default: `undefined` | ||||||||||||||||||
|
||||||||||||||||||
Determinate what is `to` option - directory, file or template. | ||||||||||||||||||
Sometimes it is hard to say what is `to`, example `path/to/dir-with.ext`. | ||||||||||||||||||
If you want to copy files in directory you need use `dir` option. | ||||||||||||||||||
We try to automatically determine the `type` so you most likely do not need this option. | ||||||||||||||||||
|
||||||||||||||||||
| Name | Type | Default | Description | | ||||||||||||||||||
| :---------------------------: | :--------: | :---------: | :--------------------------------------------------------------------------------------------------- | | ||||||||||||||||||
| **[`'dir'`](#dir)** | `{String}` | `undefined` | If `to` has no extension or ends on `'/'` | | ||||||||||||||||||
| **[`'file'`](#file)** | `{String}` | `undefined` | If `to` is not a directory and is not a template | | ||||||||||||||||||
| **[`'template'`](#template)** | `{String}` | `undefined` | If `to` contains [a template pattern](https://webpack.js.org/configuration/output/#template-strings) | | ||||||||||||||||||
| Name | Type | Default | Description | | ||||||||||||||||||
| :---------------------------: | :------: | :---------: | :--------------------------------------------------------------------------------------------------- | | ||||||||||||||||||
| **[`'dir'`](#dir)** | `string` | `undefined` | If `to` has no extension or ends on `'/'` | | ||||||||||||||||||
| **[`'file'`](#file)** | `string` | `undefined` | If `to` is not a directory and is not a template | | ||||||||||||||||||
| **[`'template'`](#template)** | `string` | `undefined` | If `to` contains [a template pattern](https://webpack.js.org/configuration/output/#template-strings) | | ||||||||||||||||||
|
||||||||||||||||||
##### `'dir'` | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -446,7 +474,12 @@ module.exports = { | |||||||||||||||||
|
||||||||||||||||||
#### `force` | ||||||||||||||||||
|
||||||||||||||||||
Type: `Boolean` | ||||||||||||||||||
Type: | ||||||||||||||||||
|
||||||||||||||||||
```ts | ||||||||||||||||||
type force = boolean; | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
Default: `false` | ||||||||||||||||||
|
||||||||||||||||||
Overwrites files already in `compilation.assets` (usually added by other plugins/loaders). | ||||||||||||||||||
|
@@ -471,7 +504,12 @@ module.exports = { | |||||||||||||||||
|
||||||||||||||||||
#### `priority` | ||||||||||||||||||
|
||||||||||||||||||
Type: `Number` | ||||||||||||||||||
Type: | ||||||||||||||||||
|
||||||||||||||||||
```ts | ||||||||||||||||||
type priority = number; | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
Default: `0` | ||||||||||||||||||
|
||||||||||||||||||
Allows to specify the priority of copying files with the same destination name. | ||||||||||||||||||
|
@@ -506,12 +544,17 @@ module.exports = { | |||||||||||||||||
|
||||||||||||||||||
#### `transform` | ||||||||||||||||||
|
||||||||||||||||||
Type: `Function|Object` | ||||||||||||||||||
Type: | ||||||||||||||||||
|
||||||||||||||||||
```ts | ||||||||||||||||||
type transform = object | ((input: string, absoluteFilename: string) => string); | ||||||||||||||||||
harish-sethuraman marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
Default: `undefined` | ||||||||||||||||||
|
||||||||||||||||||
Allows to modify the file contents. | ||||||||||||||||||
|
||||||||||||||||||
##### `Function` | ||||||||||||||||||
##### `function` | ||||||||||||||||||
|
||||||||||||||||||
**webpack.config.js** | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -535,16 +578,21 @@ module.exports = { | |||||||||||||||||
}; | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
##### `Object` | ||||||||||||||||||
##### `object` | ||||||||||||||||||
|
||||||||||||||||||
| Name | Type | Default | Description | | ||||||||||||||||||
| :-------------------------------: | :-----------------: | :---------: | :--------------------------------------------------------------------------------------------------------------- | | ||||||||||||||||||
| **[`transformer`](#transformer)** | `{Function}` | `undefined` | Allows to modify the file contents. | | ||||||||||||||||||
| **[`cache`](#cache)** | `{Boolean\|Object}` | `false` | Enable `transform` caching. You can use `transform: { cache: { key: 'my-cache-key' } }` to invalidate the cache. | | ||||||||||||||||||
| Name | Default | Description | | ||||||||||||||||||
| :-------------------------------: | :---------: | :--------------------------------------------------------------------------------------------------------------- | | ||||||||||||||||||
| **[`transformer`](#transformer)** | `undefined` | Allows to modify the file contents. | | ||||||||||||||||||
| **[`cache`](#cache)** | `false` | Enable `transform` caching. You can use `transform: { cache: { key: 'my-cache-key' } }` to invalidate the cache. | | ||||||||||||||||||
|
||||||||||||||||||
###### `transformer` | ||||||||||||||||||
|
||||||||||||||||||
Type: `Function` | ||||||||||||||||||
Type: | ||||||||||||||||||
|
||||||||||||||||||
```ts | ||||||||||||||||||
type transformer = (input: string, absoluteFilename: string) => string; | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
Default: `undefined` | ||||||||||||||||||
|
||||||||||||||||||
**webpack.config.js** | ||||||||||||||||||
|
@@ -595,15 +643,20 @@ module.exports = { | |||||||||||||||||
|
||||||||||||||||||
###### `cache` | ||||||||||||||||||
|
||||||||||||||||||
Type: `Boolean|Object` | ||||||||||||||||||
Type: | ||||||||||||||||||
|
||||||||||||||||||
```ts | ||||||||||||||||||
type cache = boolean | object; | ||||||||||||||||||
harish-sethuraman marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
Default: `false` | ||||||||||||||||||
|
||||||||||||||||||
**webpack.config.js** | ||||||||||||||||||
|
||||||||||||||||||
Enable/disable and configure caching. | ||||||||||||||||||
Default path to cache directory: `node_modules/.cache/copy-webpack-plugin`. | ||||||||||||||||||
|
||||||||||||||||||
###### `Boolean` | ||||||||||||||||||
###### `boolean` | ||||||||||||||||||
|
||||||||||||||||||
Enables/Disable `transform` caching. | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -630,7 +683,7 @@ module.exports = { | |||||||||||||||||
}; | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
##### `Object` | ||||||||||||||||||
##### `object` | ||||||||||||||||||
|
||||||||||||||||||
Enables `transform` caching and setup cache directory and invalidation keys. | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -738,7 +791,18 @@ module.exports = { | |||||||||||||||||
|
||||||||||||||||||
#### `transformAll` | ||||||||||||||||||
|
||||||||||||||||||
Type: `Function` | ||||||||||||||||||
Type: | ||||||||||||||||||
|
||||||||||||||||||
```ts | ||||||||||||||||||
type transformAll = ( | ||||||||||||||||||
data: { | ||||||||||||||||||
data: Buffer; | ||||||||||||||||||
sourceFilename: string; | ||||||||||||||||||
absoluteFilename: string; | ||||||||||||||||||
}[] | ||||||||||||||||||
) => any; | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🤔 Am I looking at the wrong type then 😕 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I thought this returned any |
||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
Default: `undefined` | ||||||||||||||||||
|
||||||||||||||||||
Allows you to modify the contents of multiple files and save the result to one file. | ||||||||||||||||||
|
@@ -777,7 +841,12 @@ module.exports = { | |||||||||||||||||
|
||||||||||||||||||
### `noErrorOnMissing` | ||||||||||||||||||
|
||||||||||||||||||
Type: `Boolean` | ||||||||||||||||||
Type: | ||||||||||||||||||
|
||||||||||||||||||
```ts | ||||||||||||||||||
type noErrorOnMissing = boolean; | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
Default: `false` | ||||||||||||||||||
|
||||||||||||||||||
Doesn't generate an error on missing file(s). | ||||||||||||||||||
|
@@ -799,7 +868,12 @@ module.exports = { | |||||||||||||||||
|
||||||||||||||||||
#### `info` | ||||||||||||||||||
|
||||||||||||||||||
Type: `Object|Function<Object>` | ||||||||||||||||||
Type: | ||||||||||||||||||
|
||||||||||||||||||
```ts | ||||||||||||||||||
type info = object | (() => object); | ||||||||||||||||||
harish-sethuraman marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
Default: `undefined` | ||||||||||||||||||
|
||||||||||||||||||
Allows to add assets info. | ||||||||||||||||||
|
@@ -844,12 +918,18 @@ module.exports = { | |||||||||||||||||
|
||||||||||||||||||
### Options | ||||||||||||||||||
|
||||||||||||||||||
| Name | Type | Default | Description | | ||||||||||||||||||
| :---------------------------: | :--------: | :-----: | :----------------------------------------------- | | ||||||||||||||||||
| [`concurrency`](#concurrency) | `{Number}` | `100` | Limits the number of simultaneous requests to fs | | ||||||||||||||||||
- [`concurrency`](#concurrency) | ||||||||||||||||||
|
||||||||||||||||||
#### `concurrency` | ||||||||||||||||||
|
||||||||||||||||||
type: | ||||||||||||||||||
|
||||||||||||||||||
```ts | ||||||||||||||||||
type concurrency = number; | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
default: `100` | ||||||||||||||||||
|
||||||||||||||||||
limits the number of simultaneous requests to fs | ||||||||||||||||||
|
||||||||||||||||||
**webpack.config.js** | ||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use types from
globby
, just use the same nameThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import("globby").Options?