Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions website/docs/en/config/output/css-modules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ import styles from './index.module.scss';
console.log(styles.header);
```

### Template string
### Placeholders

You can use the following template strings in `localIdentName`:
You can use the following placeholders in `localIdentName`:

- `[name]` - the basename of the asset.
- `[local]` - original class.
Expand Down
10 changes: 5 additions & 5 deletions website/docs/en/config/output/filename.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,22 @@ Typically, Rsbuild only sets the filename hash in production mode (`process.env.
Setting the filename hash in development mode may cause HMR to fail (especially for CSS files). This happens because each time the file content changes, the hash value changes, preventing the bundler from reading the latest file content.
:::

## Template strings
## Filename placeholders

In `output.filename`, you can use template strings to dynamically generate file names.
In `output.filename`, you can use filename placeholders to dynamically generate file names.

Common template strings include:
Common filename placeholders include:

- `[name]` - entry name, which is the key of [source.entry](/config/source/entry).
- `[contenthash]` - hash value generated based on file content.
- `[contenthash:<length>]` - hash value generated based on file content, with specified hash length.
- `[ext]` - file extension, including the dot.

> For more template strings, refer to [Rspack - Template String](https://rspack.rs/config/output#template-string).
> For more filename placeholders, refer to [Rspack - Filename placeholders](https://rspack.rs/config/filename-placeholders).

:::tip

- `filename.html` can only use certain template strings like `[name]` and `[contenthash:<length>]`.
- `filename.html` can only use certain filename placeholders like `[name]` and `[contenthash:<length>]`.
- `filename.js` and `filename.css` do not support `[ext]`.

:::
Expand Down
4 changes: 2 additions & 2 deletions website/docs/zh/config/output/css-modules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ import styles from './index.module.scss';
console.log(styles.header);
```

### 模板字符串
### 占位符

在 `localIdentName` 中,你可以使用以下模板字符串
在 `localIdentName` 中,你可以使用以下占位符

- `[name]` - 源文件名称。
- `[local]` - 原始类名。
Expand Down
10 changes: 5 additions & 5 deletions website/docs/zh/config/output/filename.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,22 @@ export default {
如果你在开发模式下设置了文件名的 hash,那么可能会导致热更新不生效(尤其是 CSS 文件)。这是因为每次文件内容变化时,都会引起 hash 变化,导致打包工具无法读取到最新的文件内容。
:::

## 模板字符串
## 文件名占位符

在 `output.filename` 的值中,你可以使用模板字符串来动态生成文件名
在 `output.filename` 的值中,你可以使用文件名占位符来动态生成文件名

常用的模板字符串有
常用的文件名占位符有

- `[name]` - entry 名称,即 [source.entry](/config/source/entry) 的 key。
- `[contenthash]` - 基于文件内容生成的 hash 值。
- `[contenthash:<length>]` - 基于文件内容生成的 hash 值,并指定 hash 长度。
- `[ext]` - 文件后缀名,包含点号。

> 更多模板字符串可以参考 [Rspack - Template String](https://rspack.rs/zh/config/output#template-string)。
> 更多文件名占位符可以参考 [Rspack - 文件名占位符](https://rspack.rs/zh/config/filename-placeholders)。

:::tip

- `filename.html` 只能使用部分模板字符串,如 `[name]`、`[contenthash:<length>]`。
- `filename.html` 只能使用部分文件名占位符,如 `[name]`、`[contenthash:<length>]`。
- `filename.js` 和 `filename.css` 不支持 `[ext]`。

:::
Expand Down
Loading