diff --git a/website/docs/en/config/lib/bundle.mdx b/website/docs/en/config/lib/bundle.mdx index 5705badf0..d66680f92 100644 --- a/website/docs/en/config/lib/bundle.mdx +++ b/website/docs/en/config/lib/bundle.mdx @@ -55,7 +55,7 @@ export default { }; ``` -You can also use with an exclamation mark to exclude some files. +You can also use with an exclamation mark to exclude some files. For example, exclude test files within the `src` folder: ```ts title="rslib.config.ts" export default { @@ -67,12 +67,28 @@ export default { ], source: { entry: { - index: ['./src/**', '!**/foo.*'], + index: ['./src/**', '!src/**/*.test.ts'], }, }, }; ``` +::: note + +If [DTS generation](/config/lib/dts) is enabled, remember to set [exclude](https://www.typescriptlang.org/tsconfig/#exclude) field in `tsconfig.json` to avoid generating TypeScript declaration files for the corresponding files. + +For example, exclude test files within the `src` folder: + +```json +// tsconfig.json +{ + "include": ["src"], + "exclude": ["src/**/*.test.ts"] +} +``` + +::: + ## Example For below file structure of source code: diff --git a/website/docs/zh/config/lib/bundle.mdx b/website/docs/zh/config/lib/bundle.mdx index 241535a40..21f678bf3 100644 --- a/website/docs/zh/config/lib/bundle.mdx +++ b/website/docs/zh/config/lib/bundle.mdx @@ -53,7 +53,7 @@ export default { }; ``` -你也可以使用感叹号来排除一些文件。 +你也可以使用感叹号来排除一些文件。例如,排除 `src` 文件夹中的测试文件: ```ts title="rslib.config.ts" export default { @@ -65,12 +65,28 @@ export default { ], source: { entry: { - index: ['./src/**', '!**/foo.*'], + index: ['./src/**', '!src/**/*.test.ts'], }, }, }; ``` +::: note + +当开启 [类型生成](/config/lib/dts) 时,记得在 `tsconfig.json` 中设置 [exclude](https://www.typescriptlang.org/tsconfig/#exclude) 字段,以避免相应的文件生成 TypeScript 类型声明文件。 + +例如,排除 `src` 文件夹中的测试文件: + +```json +// tsconfig.json +{ + "include": ["src"], + "exclude": ["src/**/*.test.ts"] +} +``` + +::: + ## Example 对于以下的源代码文件结构: