Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
13 changes: 12 additions & 1 deletion website/docs/en/config/rsbuild/source.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,18 @@ Check out the [lib.bundle](/config/lib/bundle#set-entry) to learn more about how

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

Specifies JavaScript/TypeScript files that do not need to be compiled.
Exclude JavaScript or TypeScript files that do not need to be transformed by [SWC](https://rsbuild.dev/guide/configuration/swc).

::: note

Files configured in `source.exclude` will not be transformed by SWC, but the referenced files will still be bundled into the outputs.

If you want certain files not to be bundled into the outputs, you can use the following methods:

- **bundle mode**: Use Rspack's [IgnorePlugin](https://rspack.dev/plugins/webpack/ignore-plugin).
- **bundleless mode**: Use `source.entry` to configure the corresponding glob expression, refer to [Set entry](/config/lib/bundle#bundle-false).

:::

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

Expand Down
13 changes: 12 additions & 1 deletion website/docs/zh/config/rsbuild/source.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,18 @@ const defaultEntry = {

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

指定不需要编译的 JavaScript/TypeScript 文件。
排除不需要被 [SWC](https://rsbuild.dev/zh/guide/configuration/swc) 编译的 JavaScript 或 TypeScript 文件。

::: note

在 `source.exclude` 中配置的文件不会经过 SWC 转译,但被引用的文件仍然会被打包到产物中。

如果你希望某些文件不被打包到产物中,可以使用以下方法:

- **bundle 模式**:使用 Rspack 的 [IgnorePlugin](https://rspack.dev/zh/plugins/webpack/ignore-plugin)。
- **bundleless 模式**:使用 `source.entry` 配置相应的 glob 表达式,参考 [设置入口](/config/lib/bundle#bundle-false)。

:::

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

Expand Down
Loading