Skip to content

Commit effa6b0

Browse files
authored
docs: optimize source.exclude description (#1009)
1 parent 892a8e7 commit effa6b0

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,18 @@ Check out the [lib.bundle](/config/lib/bundle#set-entry) to learn more about how
4848

4949
## source.exclude <RsbuildDocBadge path="/config/source/exclude" text="source.exclude" />
5050

51-
Specifies JavaScript/TypeScript files that do not need to be compiled.
51+
Exclude JavaScript or TypeScript files that do not need to be transformed by [SWC](https://rsbuild.dev/guide/configuration/swc).
52+
53+
::: note
54+
55+
Files configured in `source.exclude` will not be transformed by SWC, but the referenced files will still be bundled into the outputs.
56+
57+
If you want certain files not to be bundled into the outputs, you can use the following methods:
58+
59+
- **bundle mode**: Use Rspack's [IgnorePlugin](https://rspack.dev/plugins/webpack/ignore-plugin).
60+
- **bundleless mode**: Use `source.entry` to configure the corresponding glob expression, refer to [Set entry](/config/lib/bundle#bundle-false).
61+
62+
:::
5263

5364
## source.include <RsbuildDocBadge path="/config/source/include" text="source.include" />
5465

website/docs/zh/config/rsbuild/source.mdx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,18 @@ const defaultEntry = {
4747

4848
## source.exclude <RsbuildDocBadge path="/config/source/exclude" text="source.exclude" />
4949

50-
指定不需要编译的 JavaScript/TypeScript 文件。
50+
排除不需要被 [SWC](https://rsbuild.dev/zh/guide/configuration/swc) 转译的 JavaScript 或 TypeScript 文件。
51+
52+
::: note
53+
54+
`source.exclude` 中配置的文件不会经过 SWC 转译,但被引用的文件仍然会被打包到产物中。
55+
56+
如果你希望某些文件不被打包到产物中,可以使用以下方法:
57+
58+
- **bundle 模式**:使用 Rspack 的 [IgnorePlugin](https://rspack.dev/zh/plugins/webpack/ignore-plugin)
59+
- **bundleless 模式**:使用 `source.entry` 配置相应的 glob 表达式,参考 [设置入口](/config/lib/bundle#bundle-false)
60+
61+
:::
5162

5263
## source.include <RsbuildDocBadge path="/config/source/include" text="source.include" />
5364

0 commit comments

Comments
 (0)