Skip to content

Commit 0b89e80

Browse files
committed
chore: update
1 parent db463a7 commit 0b89e80

File tree

7 files changed

+65
-66
lines changed

7 files changed

+65
-66
lines changed

website/docs/en/config/rsbuild/output.mdx

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Options for build outputs.
88

99
Use this option to set the URL prefix for static assets, such as setting it to a CDN URL.
1010

11-
In cases where the [format](/config/lib/format) is set to `cjs` or `esm`, Rslib sets `output.assetPrefix` to `"auto"`.
11+
When [format](/config/lib/format) is set to `cjs` or `esm`, Rslib defaults to setting `output.assetPrefix` to `"auto"`.
1212

1313
## output.charset <RsbuildDocBadge path="/config/output/charset" text="output.charset" />
1414

@@ -30,6 +30,8 @@ For custom CSS Modules configuration.
3030

3131
Set the size threshold to inline static assets such as images and fonts.
3232

33+
When [format](/config/lib/format) is set to `cjs` or `esm`, Rslib defaults to setting `output.dataUriLimit` to `0`, without inlining any static assets, so that build tools on the application side can handle and optimize them.
34+
3335
## output.distPath <RsbuildDocBadge path="/config/output/dist-path" text="output.distPath" />
3436

3537
Set the directory of the dist files. Rsbuild will output files to the corresponding subdirectory according to the file type.

website/docs/en/guide/advanced/json-files.mdx

+15-14
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ Rslib supports import JSON files in code.
44

55
## JSON file
66

7-
You can directly reference JSON files in JavaScript files.
7+
You can directly import JSON files in JavaScript files.
8+
9+
:::warning
10+
11+
In bundle mode, JSON files support both default and named import.
12+
13+
In bundleless mode, JSON files only support named import.
14+
15+
:::
816

917
### Default import
1018

@@ -22,16 +30,9 @@ console.log(example.name); // 'foo';
2230
console.log(example.items); // [1, 2];
2331
```
2432

25-
:::warning
26-
27-
In Bundle mode, JSON files support both default and named imports.
28-
In Bundleless mode, JSON files only support named imports.
29-
30-
:::
31-
3233
### Named import
3334

34-
Rslib also supports referencing JSON files through named imports:
35+
Rslib also supports importing JSON files through named import.
3536

3637
Here is an example, assuming the source code is as follows:
3738

@@ -59,25 +60,25 @@ console.log(name); // 'foo';
5960
</Tab>
6061
</Tabs>
6162

62-
Based on the configuration in the [output structure](/guide/basic/output-structure) specified in the configuration file, the following outputs will be packaged:
63+
Based on the configuration in the [output structure](/guide/basic/output-structure) specified in the configuration file, the following outputs will be emitted:
6364

6465
<Tabs>
65-
<Tab label="Bundle">
66+
<Tab label="bundle">
6667
<Tabs>
6768
<Tab label="dist/index.js">
6869

6970
```tsx
7071
var example_namespaceObject = {
71-
name: 'foo',
72+
u: 'foo',
7273
};
73-
console.log(example_namespaceObject.name);
74+
console.log(example_namespaceObject.u);
7475
```
7576

7677
</Tab>
7778
</Tabs>
7879
</Tab>
7980

80-
<Tab label="Bundleless">
81+
<Tab label="bundleless">
8182

8283
<Tabs>
8384
<Tab label="dist/index.js">

website/docs/en/guide/advanced/static-assets.mdx

+13-15
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ To import assets in other formats, refer to [Extend Asset Types](#extend-asset-t
1515

1616
## Import assets in JS file
1717

18-
In JS files, you can directly refer to static assets with relative paths through `import`:
18+
In JS files, you can directly import static assets with relative paths through `import`:
1919

2020
```tsx
2121
// Import the logo.png image in the 'src/assets' directory
@@ -36,7 +36,7 @@ console.log(logo); // "/static/logo.[hash].png"
3636
export default = () => <img src={logo} />;
3737
```
3838

39-
When the [format](/config/lib/format) is set to `cjs` or `esm`, Rslib treats the output as an mid-level artifact that will be consumed by other build tools again. During the code transformation, Rslib transforms the source file into a JS file and a static asset file that is output according to [output.distPath](/config/rsbuild/output#outputdistpath), which is used to preserve the `import` statements for static assets.
39+
When the [format](/config/lib/format) is set to `cjs` or `esm`, Rslib treats the output as an mid-level artifact that will be consumed by other build tools again and transforms the source file into a JS file and a static asset file that is emitted according to [output.distPath](/config/rsbuild/output#outputdistpath) by default, which is used to preserve the `import` statements for static assets.
4040

4141
The following is an example of usage, assuming the source code is as follows:
4242

@@ -57,10 +57,10 @@ console.log(logo);
5757
</Tab>
5858
</Tabs>
5959

60-
Based on the configuration in the [output structure](/guide/basic/output-structure) in the configuration file, the following outputs will be packaged:
60+
Based on the configuration in the [output structure](/guide/basic/output-structure) in the configuration file, the following outputs will be emitted:
6161

6262
<Tabs>
63-
<Tab label="Bundle">
63+
<Tab label="bundle">
6464
<Tabs>
6565
<Tab label="dist/index.mjs">
6666

@@ -77,7 +77,7 @@ console.log(logo_rslib_entry_namespaceObject);
7777
</Tabs>
7878
</Tab>
7979

80-
<Tab label="Bundleless">
80+
<Tab label="bundleless">
8181

8282
<Tabs>
8383
<Tab label="dist/index.mjs">
@@ -123,7 +123,7 @@ Import with **alias** are also supported:
123123
}
124124
```
125125

126-
When the [format](/config/lib/format) is `cjs` or `esm`, Rslib treats the output as an intermediate product that will be consumed again by other packaging tools. Rslib preserves relative reference paths in CSS outputs by setting [output.assetPrefix](/config/rsbuild/output#outputassetprefix) to `"auto"`.
126+
When the [format](/config/lib/format) is set to `cjs` or `esm`, Rslib treats the output as an mid-level artifact that will be consumed by other build tools again and preserves relative reference paths in CSS outputs by default via setting [output.assetPrefix](/config/rsbuild/output#outputassetprefix) to `"auto"`.
127127

128128
The following is an example of usage, assuming the source code is as follows:
129129

@@ -147,7 +147,7 @@ The following is an example of usage, assuming the source code is as follows:
147147
</Tab>
148148
</Tabs>
149149

150-
The following output will be packaged:
150+
The following output will be emitted:
151151

152152
<Tabs>
153153

@@ -185,7 +185,7 @@ If you need to import a static asset with an absolute path in a CSS file:
185185
}
186186
```
187187

188-
By default, the built-in `css-loader` in Rslib will resolve absolute paths in `url()` and look for the specified modules. If you want to skip resolving absolute paths, you can configure [`tools.cssLoader`](/config/rsbuild/tools#toolscssloader) to filter out the specified paths. The filtered paths are left as they are in the code.
188+
By default, the built-in `css-loader` in Rslib will resolve absolute paths in `url()` and look for the specified modules. If you want to skip resolving absolute paths, you can configure [`tools.cssLoader`](/config/rsbuild/tools#toolscssloader) to filter out the specified paths. The filtered paths are preserved as they are in the code.
189189

190190
```ts
191191
export default {
@@ -206,16 +206,14 @@ export default {
206206

207207
## Inline static assets
208208

209-
When developing libraries that will be consumed again by other build tools as intermediate products, static assets are typically not inlined, leaving the handling and optimization to the build tools on the application side.
210-
211-
The automatic inlining size threshold can be modified via the [output.dataUriLimit](/config/rsbuild/output#outputdataurilimit) configuration option. When the [format](/config/lib/format) is `cjs` or `esm`, Rslib defaults the `output.dataUriLimit` to `0`, not inlining any static assets.
209+
When the [format](/config/lib/format) is set to `cjs` or `esm`, Rslib treats the output as an mid-level artifact that will be consumed by other build tools again and sets [output.dataUriLimit](/config/rsbuild/output#outputdataurilimit) to `0` by default to not inline any static assets.
212210

213211
## Build output directory
214212

215-
Once static assets are referenced, they will automatically be output to the build output directory. You can:
213+
Once static assets are imported, they will automatically be output to the build output directory. You can:
216214

217-
- Modify the filename of the output through [output.filename](/config/rsbuild/output#outputfilename).
218-
- Change the output path of the product through [output.distPath](/config/rsbuild/output#outputdistpath).
215+
- Modify the filename of the outputs through [output.filename](/config/rsbuild/output#outputfilename).
216+
- Change the output path of the outputs through [output.distPath](/config/rsbuild/output#outputdistpath).
219217

220218
## Type declaration
221219

@@ -282,7 +280,7 @@ export default {
282280
addRules([
283281
{
284282
test: /\.pdf$/,
285-
// 将资源转换为单独的文件,并且保留 import 语句
283+
// Convert assets to separate files and keep import statements
286284
type: 'asset/resource',
287285
generator: {
288286
importMode: 'preserve',

website/docs/en/guide/advanced/svgr-files.mdx

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
By default, Rslib treats SVG images as static assets.
44

5-
By adding the [@rsbuild/plugin-svgr](https://rsbuild.dev/plugins/list/plugin-svgr) plugin, Rslib supports invoking [SVGR](https://react-svgr.com/) to convert SVG images into React components for use.
5+
By adding the [@rsbuild/plugin-svgr](https://rsbuild.dev/plugins/list/plugin-svgr) plugin, Rslib supports transforming SVG to React components via [SVGR](https://react-svgr.com/).
66

77
## Quick start
88

@@ -30,7 +30,7 @@ export default {
3030

3131
### Bundle mode
3232

33-
In Bundle mode, all usages supported by the [Rsbuild SVGR plugin](https://rsbuild.dev/plugins/list/plugin-svgr) are available. The only difference is that when using an SVG file in URL form, Rslib will retain the `import` statement for the static asset in the output according to [Referencing Static Assets](/guide/advanced/static-assets).
33+
In bundle mode, all usages supported by [@rsbuild/plugin-svgr](https://rsbuild.dev/plugins/list/plugin-svgr) are available in Rslib. The only difference is that when using an SVG file in URL form, Rslib will retain the `import` statement for the static asset in the output according to [Import static assets](/guide/advanced/static-assets).
3434

3535
Here is an example of usage:
3636

@@ -50,14 +50,14 @@ import logoURL from './static/logo.svg';
5050
console.log(logoURL);
5151
```
5252

53-
`@rsbuild/plugin-svgr` also supports default imports and mixed imports:
53+
`@rsbuild/plugin-svgr` also supports default import and mixed import:
5454

55-
- Enable default imports by setting [svgrOptions.exportType](https://rsbuild.dev/plugins/list/plugin-svgr#svgroptionsexporttype) to `'default'`.
56-
- Enable mixed imports through the [mixedImport](https://rsbuild.dev/plugins/list/plugin-svgr#mixedimport) option to use both default and named imports.
55+
- Enable default import by setting [svgrOptions.exportType](https://rsbuild.dev/plugins/list/plugin-svgr#svgroptionsexporttype) to `'default'`.
56+
- Enable mixed import through the [mixedImport](https://rsbuild.dev/plugins/list/plugin-svgr#mixedimport) option to use both default and named import.
5757

5858
### Bundleless mode
5959

60-
In Bundleless mode, since each file undergoes code transformation independently, the import ways of `?react` and `?url` are not supported. However, the following two usage forms are supported:
60+
In bundleless mode, since each file undergoes code transformation independently, the import ways of `?react` and `?url` are not supported. However, the following two usage forms are supported:
6161

6262
#### Named import
6363

@@ -77,14 +77,14 @@ import { ReactComponent as Logo } from './logo.svg';
7777
export const App = () => <Logo />;
7878
```
7979

80-
All `.svg` files will be converted into React components. At this time, you can:
80+
All `.svg` files will be transformed into React components. At this time, you can:
8181

82-
- Exclude files that do not need to be converted by setting [exclude](https://rsbuild.dev/plugins/list/plugin-svgr#exclude).
82+
- Exclude files that do not need to be transformed by setting [exclude](https://rsbuild.dev/plugins/list/plugin-svgr#exclude).
8383
- Change to default export by setting [svgrOptions.exportType](https://rsbuild.dev/plugins/list/plugin-svgr#svgroptionsexporttype) to `'default'`.
8484

8585
#### Mixed import
8686

87-
If your library has both URL and React component import forms for SVG files, you can also use mixed imports.
87+
If your library has both URL and React component import forms for SVG files, you can also use mixed import.
8888

8989
```ts
9090
pluginSvgr({

website/docs/zh/guide/advanced/json-files.mdx

+14-14
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ Rslib 支持在代码中引用 JSON 文件。
66

77
你可以直接在 JavaScript 文件中引用 JSON 文件。
88

9+
:::warning
10+
11+
在 bundle 模式下,JSON 文件支持默认引用和具名引用。
12+
13+
在 bundleless 模式下,JSON 文件仅支持具名引用。
14+
15+
:::
16+
917
### 默认引用
1018

1119
```json title="example.json"
@@ -22,17 +30,9 @@ console.log(example.name); // 'foo';
2230
console.log(example.items); // [1, 2];
2331
```
2432

25-
:::warning
26-
27-
在 Bundle 模式下,JSON 文件支持默认引用和具名引用。
28-
29-
在 Bundleless 模式下,JSON 文件仅支持具名引用。
30-
31-
:::
32-
3333
### 具名引用
3434

35-
Rslib 同样支持通过 named import 来引用 JSON 文件
35+
Rslib 同样支持通过 named import 来引用 JSON 文件
3636

3737
下面是一个使用示例,假设源码如下:
3838

@@ -60,24 +60,24 @@ console.log(name); // 'foo';
6060
</Tab>
6161
</Tabs>
6262

63-
会根据配置文件中的 [产物结构](/guide/basic/output-structure) 配置,打包出如下产物
63+
会根据配置文件中的 [产物结构](/guide/basic/output-structure) 配置,输出如下产物
6464

6565
<Tabs>
66-
<Tab label="Bundle">
66+
<Tab label="bundle">
6767
<Tabs>
6868
<Tab label="dist/index.js">
6969
```tsx
7070
var example_namespaceObject = {
71-
"name": "foo"
71+
u: 'foo',
7272
};
73-
console.log(example_namespaceObject.name);
73+
console.log(example_namespaceObject.u);
7474
```
7575

7676
</Tab>
7777
</Tabs>
7878
</Tab>
7979

80-
<Tab label="Bundleless">
80+
<Tab label="bundleless">
8181

8282
<Tabs>
8383
<Tab label="dist/index.js">

website/docs/zh/guide/advanced/static-assets.mdx

+8-10
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ console.log(logo); // "/static/logo.[hash].png"
3636
export default = () => <img src={logo} />;
3737
```
3838

39-
[format](/config/lib/format)`cjs``esm` 时,Rslib 将产物视为会被其他打包工具再次消费的中间产物。Rslib 会在代码转换时将源文件转化为一个 JS 文件和一个根据 [output.distPath](/config/rsbuild/output#outputdistpath) 输出的静态资源文件,用于保留对静态资源的 `import` 语句。
39+
[format](/config/lib/format)`cjs``esm` 时,Rslib 将产物视为会被其他打包工具再次消费的中间产物,默认会在代码转换时将源文件转化为一个 JS 文件和一个根据 [output.distPath](/config/rsbuild/output#outputdistpath) 输出的静态资源文件,从而保留引用静态资源的 `import` 语句。
4040

4141
下面是一个使用示例,假设源码如下:
4242

@@ -57,10 +57,10 @@ console.log(logo);
5757
</Tab>
5858
</Tabs>
5959

60-
会根据配置文件中的 [产物结构](/guide/basic/output-structure) 配置,打包出如下产物
60+
会根据配置文件中的 [产物结构](/guide/basic/output-structure) 配置,输出如下产物
6161

6262
<Tabs>
63-
<Tab label="Bundle">
63+
<Tab label="bundle">
6464
<Tabs>
6565
<Tab label="dist/index.mjs">
6666

@@ -77,7 +77,7 @@ console.log(logo_rslib_entry_namespaceObject);
7777
</Tabs>
7878
</Tab>
7979

80-
<Tab label="Bundleless">
80+
<Tab label="bundleless">
8181

8282
<Tabs>
8383
<Tab label="dist/index.mjs">
@@ -123,7 +123,7 @@ export { logo_rslib_entry_namespaceObject as default };
123123
}
124124
```
125125

126-
[format](/config/lib/format)`cjs``esm` 时,Rslib 将产物视为会被其他打包工具再次消费的中间产物。Rslib 会通过设置 [output.assetPrefix](/config/rsbuild/output#outputassetprefix) `"auto"` 来使 CSS 产物中保留相对引用路径。
126+
[format](/config/lib/format)`cjs``esm` 时,Rslib 将产物视为会被其他打包工具再次消费的中间产物,默认会将 [output.assetPrefix](/config/rsbuild/output#outputassetprefix) 设置为 `"auto"` 来使 CSS 产物中保留相对引用路径。
127127

128128
下面是一个使用示例,假设源码如下:
129129

@@ -147,7 +147,7 @@ export { logo_rslib_entry_namespaceObject as default };
147147
</Tab>
148148
</Tabs>
149149

150-
会打包出如下产物
150+
会输出如下产物
151151

152152
<Tabs>
153153

@@ -206,9 +206,7 @@ export default {
206206

207207
## 静态资源内联
208208

209-
在开发组件库这种会被其他打包工具再次消费的中间产物时,一般不会内联静态资源,交给应用侧的构建工具处理和优化。
210-
211-
自动内联的体积阈值可以通过 [output.dataUriLimit](/config/rsbuild/output#outputdataurilimit) 配置项修改,在 [format](/config/lib/format)`cjs``esm` 时,Rslib 默认会将 `output.dataUriLimit` 设置为 `0`,不内联任何静态资源。
209+
[format](/config/lib/format)`cjs``esm` 时,Rslib 将产物视为会被其他打包工具再次消费的中间产物,默认会将 [output.dataUriLimit](/config/rsbuild/output#outputdataurilimit) 设置为 `0` 以不内联任何静态资源。
212210

213211
## 构建产物目录
214212

@@ -294,4 +292,4 @@ export default {
294292
};
295293
```
296294

297-
关于 asset modules 的更多介绍,请参考 [Rspack - Asset modules](https://rspack.dev/guide/features/asset-module)
295+
关于资源模块的更多介绍,请参考 [Rspack - 资源模块](https://rspack.dev/zh/guide/features/asset-module)

website/docs/zh/guide/advanced/svgr-files.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default {
3030

3131
### Bundle 模式
3232

33-
Bundle 模式下,支持 [Rsbuild SVGR 插件](https://rsbuild.dev/zh/plugins/list/plugin-svgr) 下的所有用法,唯一的区别是当以 URL 形式使用 SVG 文件时,Rslib 会按照 [引用静态资源](/zh/guide/advanced/static-assets) 在产物中对应保留静态资源的 `import` 语句。
33+
bundle 模式下,Rslib 支持 [@rsbuild/plugin-svgr](https://rsbuild.dev/zh/plugins/list/plugin-svgr) 下的所有用法,唯一的区别是当以 URL 形式使用 SVG 文件时,Rslib 会按照 [引用静态资源](/guide/advanced/static-assets) 在产物中对应保留静态资源的 `import` 语句。
3434

3535
下面是一个使用示例:
3636

@@ -40,7 +40,7 @@ import Logo from './logo.svg?react';
4040
export const App = () => <Logo />;
4141
```
4242

43-
如果导入的路径不包含 `?react` 后缀,那么 SVG 会被当做普通的静态资源来处理,保留对静态资源的 `import` 语句。
43+
如果导入的路径不包含 `?react` 后缀,那么 SVG 会被当做普通的静态资源来处理,即保留对静态资源的 `import` 语句。
4444

4545
```js
4646
import logoURL from './static/logo.svg';
@@ -55,7 +55,7 @@ console.log(logoURL);
5555

5656
### Bundleless 模式
5757

58-
Bundleless 模式下,由于每个文件都是独立经过代码转换,因此不支持 `?react``?url` 的引用形式,但支持下面两种使用形式:
58+
bundleless 模式下,由于每个文件都是独立经过代码转换,因此不支持 `?react``?url` 的引用形式,但支持下面两种使用形式:
5959

6060
#### 具名导入
6161

0 commit comments

Comments
 (0)