diff --git a/website/docs/en/config/rsbuild/source.mdx b/website/docs/en/config/rsbuild/source.mdx index d5ee21ca7..f6532dfef 100644 --- a/website/docs/en/config/rsbuild/source.mdx +++ b/website/docs/en/config/rsbuild/source.mdx @@ -48,7 +48,18 @@ Check out the [lib.bundle](/config/lib/bundle#set-entry) to learn more about how ## 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 diff --git a/website/docs/zh/config/rsbuild/source.mdx b/website/docs/zh/config/rsbuild/source.mdx index 068af35ee..00d1e7e44 100644 --- a/website/docs/zh/config/rsbuild/source.mdx +++ b/website/docs/zh/config/rsbuild/source.mdx @@ -47,7 +47,18 @@ const defaultEntry = { ## 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