Skip to content

Commit

Permalink
docs: support function handler in progress plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
9aoy committed Sep 29, 2024
1 parent b90321f commit 0c0ee3f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 10 deletions.
29 changes: 24 additions & 5 deletions website/docs/en/plugins/webpack/progress-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,40 @@ new rspack.ProgressPlugin(options);

## Options

### prefix
### Function

Provide a handler function which will be called when hooks report progress. `handler` function arguments:

- `percentage`: a number between 0 and 1 indicating the completion percentage of the compilation
- `message`: a short description of the currently-executing hook
- `...args`: zero or more additional strings describing the current progress

```js
const handler = (percentage, message, ...args) => {
// e.g. Output each progress message directly to the console:
console.info(percentage, message, ...args);
};

new rspack.ProgressPlugin(handler);
```

### Object

#### prefix

- **Type:** `string`
- **Default:** `'Rspack'`

The text will be displayed before the progress bar.

### profile
#### profile

- **Type:** `boolean`
- **Default:** `false`

Tells `ProgressPlugin` to collect profile data for progress steps.

### template
#### template

- **Type:** `string`
- **Default:** `● {prefix:.bold} {bar:25.green/white.dim} ({percent}%) {wide_msg:.dim}`
Expand All @@ -35,7 +54,7 @@ The template of progress bar.

Also see [indicatif::ProgressBar::with_template](https://docs.rs/indicatif/latest/indicatif/style/struct.ProgressStyle.html#method.with_template).

### tick
#### tick

- **Type:** `string | string[] | undefined`
- **Default:** `undefined`
Expand All @@ -44,7 +63,7 @@ The tick string sequence for spinners, if it's string then it will be split into

Also see [indicatif::ProgressBar::tick_strings](https://docs.rs/indicatif/latest/indicatif/style/struct.ProgressStyle.html#method.tick_strings).

### progressChars
#### progressChars

- **Type:** `string`
- **Default:** `━━`
Expand Down
29 changes: 24 additions & 5 deletions website/docs/zh/plugins/webpack/progress-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,40 @@ new rspack.ProgressPlugin(options);

## 选项

### prefix
### Function

提供一个处理函数,当 hooks 进度更新时将调用该函数。`handler` 函数参数为:

- `percentage`:0 到 1 之间的数字,表示编译的完成百分比
- `message`:关于当前执行 hook 的简短描述
- `...args`:零个或多个描述当前进度的附加字符串

```js
const handler = (percentage, message, ...args) => {
// e.g. Output each progress message directly to the console:
console.info(percentage, message, ...args);
};

new rspack.ProgressPlugin(handler);
```

### Object

#### prefix

- **Type:** `string`
- **Default:** `'Rspack'`

进度条前显示文案。

### profile
#### profile

- **Type:** `boolean`
- **Default:** `false`

是否收集进度步骤的性能数据。

### template
#### template

- **Type:** `string`
- **Default:** `● {prefix:.bold} {bar:25.green/white.dim} ({percent}%) {wide_msg:.dim}`
Expand All @@ -35,7 +54,7 @@ new rspack.ProgressPlugin(options);

详情查阅 [indicatif::ProgressBar::with_template](https://docs.rs/indicatif/latest/indicatif/style/struct.ProgressStyle.html#method.with_template).

### tick
#### tick

- **Type:** `string | string[] | undefined`
- **Default:** `undefined`
Expand All @@ -44,7 +63,7 @@ Spinner 变化的字符串序列,如果是字符串,则会被拆分为字符

详情查阅 [indicatif::ProgressBar::tick_strings](https://docs.rs/indicatif/latest/indicatif/style/struct.ProgressStyle.html#method.tick_strings).

### progressChars
#### progressChars

- **Type:** `string`
- **Default:** `━━`
Expand Down

0 comments on commit 0c0ee3f

Please sign in to comment.