Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 18 additions & 2 deletions website/docs/en/config/lib/bundle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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:
Expand Down
20 changes: 18 additions & 2 deletions website/docs/zh/config/lib/bundle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default {
};
```

你也可以使用感叹号来排除一些文件。
你也可以使用感叹号来排除一些文件。例如,排除 `src` 文件夹中的测试文件:

```ts title="rslib.config.ts"
export default {
Expand All @@ -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

对于以下的源代码文件结构:
Expand Down
Loading