Skip to content

Commit

Permalink
docs: update tools.htmlPlugin options tip (#3561)
Browse files Browse the repository at this point in the history
Co-authored-by: neverland <[email protected]>
  • Loading branch information
9aoy and chenjiahan authored Sep 25, 2024
1 parent c71ac66 commit 0a0666e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions website/docs/en/config/tools/html-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ const defaultOptions = {

The configs of [html-rspack-plugin](https://github.com/rspack-contrib/html-rspack-plugin) can be modified through `tools.htmlPlugin`.

:::tip
Rsbuild internally implements HTML-related features based on [html-rspack-plugin](https://github.com/rspack-contrib/html-rspack-plugin). It is a fork of [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin), with the same features and options.

:::tip
If you need to modify options such as `title`, `template`, `templateParameters`, `meta`, it is recommended to use the corresponding HTML configurations provided by Rsbuild first, such as [html.title](/config/html/title), [html .template](/config/html/template) etc.

This is because Rsbuild provides some internal optimization processing for these HTML configurations. For example, if the HTML template used by the current project already contains the `<title>` tag, then `html.title` will not take effect.
:::

### Object Type
## Object Type

When `tools.htmlPlugin` is `Object` type, the value will be merged with the default config via `Object.assign`.

Expand All @@ -36,7 +40,7 @@ export default {
};
```

### Function Type
## Function Type

When `tools.htmlPlugin` is a Function:

Expand Down
10 changes: 7 additions & 3 deletions website/docs/zh/config/tools/html-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ const defaultOptions = {

通过 `tools.htmlPlugin` 可以修改 [html-rspack-plugin](https://github.com/rspack-contrib/html-rspack-plugin) 的配置项。

:::tip
Rsbuild 内部基于 [html-rspack-plugin](https://github.com/rspack-contrib/html-rspack-plugin) 实现 HTML 相关的能力。它是 [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin) 的一个 fork 版本,具备完全一致的功能和选项。

:::tip
如果你需要修改 `title``template``templateParameters``meta` 等选项,推荐优先使用 Rsbuild 提供的对应 HTML 配置项,如 [html.title](/config/html/title)[html.template](/config/html/template) 等。

这是因为这些配置间存在一些关联关系,Rsbuild 对于 HTML 配置项提供了一些内部的优化处理,例如,如果当前项目使用的 HTML 模板中已经包含了 `<title>` 标签,那么 `html.title` 将不会生效。
:::

### Object 类型
## Object 类型

`tools.htmlPlugin` 的值为 `Object` 类型时,会与默认配置通过 `Object.assign` 合并。

Expand All @@ -36,7 +40,7 @@ export default {
};
```

### Function 类型
## Function 类型

`tools.htmlPlugin` 为 Function 类型时:

Expand Down

0 comments on commit 0a0666e

Please sign in to comment.