Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(module-doc): update content about input config #4587

Merged
merged 3 commits into from
Sep 6, 2023
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
6 changes: 6 additions & 0 deletions .changeset/gentle-turtles-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/module-tools-docs': patch
---

docs(module-doc): update content about `input` config
docs(module-doc): 更新关于 input 配置的内容
27 changes: 27 additions & 0 deletions packages/document/module-doc/docs/en/api/config/build-config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -596,14 +596,41 @@ type Input =

**Array usage:**

In `bundle` mode, the following configurations will be built using `src/index.ts` and `src/index2.ts` as entry points. The `bundle` mode does not support configuring `input` as a directory.

```js title="modern.config.ts"
export default {
buildConfig: {
buildType: 'bundle',
input: ['src/index.ts', 'src/index2.ts'],
},
};
```

In `bundleless` mode, the following configuration compiles both files in the `src/a` directory and `src/index.ts` file.

```js title="modern.config.ts"
export default defineConfig({
buildConfig: {
buildType: 'bundleless',
input: ['src/a', 'src/index.ts'],
},
});
```

In `bundleless` mode, **Array usage** also supports the usage of `!` to filter partial files:

```js title="modern.config.ts"
export default defineConfig({
buildConfig: {
buildType: 'bundleless',
input: ['src', '!src/*.spec.ts'],
},
});
```

The above configuration will build the files in the `src` directory, and will also filter files with the `spec.ts` suffix.This is useful in cases where the test files are in the same root directory as the source files.

**Object usage:**

When you need to modify the output file name in bundle mode, you can use an object configuration.
Expand Down
28 changes: 28 additions & 0 deletions packages/document/module-doc/docs/zh/api/config/build-config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -594,14 +594,42 @@ type Input =

**数组用法:**

在 `bundle` 模式下,下面的配置会以 `src/index.ts` 和 `src/index2.ts` 为入口分别进行构建。`bundle` 模式不支持配置 `input` 为目录。

```js title="modern.config.ts"
export default defineConfig({
buildConfig: {
buildType: 'bundle',
input: ['src/index.ts', 'src/index2.ts'],
},
});
```

在 `bundleless` 模式下,下面的配置会同时处理 `src/a` 目录下的文件和 `src/index.ts` 文件。

```js title="modern.config.ts"
export default defineConfig({
buildConfig: {
buildType: 'bundleless',
input: ['src/a', 'src/index.ts'],
},
});
```

在 `bundleless` 模式下,数组模式还支持使用 `!` 来过滤部分文件:

```js title="modern.config.ts"
export default defineConfig({
buildConfig: {
buildType: 'bundleless',
input: ['src', '!src/*.spec.ts'],
},
});
```

上面的配置将打包 `src` 目录下的文件,同时会过滤以 `spec.ts` 为后缀的文件。这在测试文件与源码文件在同一个根目录下的情况会很有用。


**对象用法:**

当在 bundle 模式下需要修改产物的输出文件名称的时候,可以使用对象形式进行配置。
Expand Down