Skip to content

Commit

Permalink
docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhanbo committed Jul 25, 2024
1 parent b142814 commit 3bea852
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ export default defineConfig({
> Different from using `viteConfig.server.proxy` by default for http mock, `websocket mock` does not use the ws-related configuration in `viteConfig.server.proxy`. Also, rules configured in `wsPrefix` cannot be configured simultaneously in `viteConfig.server.proxy`, as it will cause conflicts when starting the vite server because multiple instances of WebSocketServer cannot be implemented for the same request.
> This conflict is neither a problem with Vite nor with the plugin; it belongs to a reasonable error type. When switching between WebSocket Mock and WebSocket Proxy, please pay attention to avoid duplicate configurations that may cause conflicts.
- `option.cwd`

**Type:** `string`

Configure the matching context for `include` and `exclude`.

**Default:** `process.cwd()`

- `option.include`

**Type:** `string | string[]`
Expand Down
8 changes: 8 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ export default defineConfig({
> 与 http mock 默认使用 `viteConfig.server.proxy` 不同的是,`websocket mock` 不会使用 `viteConfig.server.proxy` 中的 ws 相关的配置,且配置在 `wsPrefix` 中的规则,不能同时配置在 `viteConfig.server.proxy`中,因为会导致在 vite 在启动服务时产生冲突,因为不能对同一个请求实现多个的 `WebSocketServer`实例。
> 该冲突既不是 `vite` 的问题,也不是插件的问题,这属于合理的错误类型。在进行 `WebSocket Mock``WebSocket Proxy` 切换时,请注意配置不要出现重复导致冲突。
- `option.cwd`

**类型:** `string`

配置 `include``exclude` 的匹配上下文

**默认值:** `process.cwd()`

- `option.include`

**类型:** `string | string[]`
Expand Down
12 changes: 10 additions & 2 deletions docs/en/guide/plugin-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,20 @@ Unlike the default behavior of using `viteConfig.server.proxy` for HTTP mocks, W

This conflict is not a problem with Vite or the plugin itself; it is a reasonable type of error. When switching between WebSocket Mock and WebSocket Proxy, please ensure that the configuration does not contain duplicates that could cause conflicts.

## cwd

**Type**`string`

**Default**`process.cwd()`

Configure the matching context for `include` and `exclude`.

## include

**Type**`string | string[]`

**Default**
`['mock/**/*.mock.{js,ts,cjs,mjs,json,json5}']` relative to root
`['mock/**/*.mock.{js,ts,cjs,mjs,json,json5}']` relative to [`cwd`](#cwd)

Configure the reading of mock files, which can be a directory, a glob pattern, or an array.

Expand All @@ -80,7 +88,7 @@ Configure the reading of mock files, which can be a directory, a glob pattern, o
**Type**`string | string[]`

**Default**
`['**/node_modules/**','**/test/**','**/cypress/**','src/**','**/.vscode/**','**/.git/**','**/dist/**']`
`['**/node_modules/**','**/test/**','**/cypress/**','src/**','**/.vscode/**','**/.git/**','**/dist/**']` relative to [`cwd`](#cwd)

Specifies the files to be excluded when reading mock files. It can be a directory, glob pattern, or an array.

Expand Down
12 changes: 10 additions & 2 deletions docs/guide/plugin-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,20 @@ interface MockServerPluginOptions {

该冲突既不是 `vite` 的问题,也不是插件的问题,这属于合理的错误类型。在进行 `WebSocket Mock``WebSocket Proxy` 切换时,请注意配置不要出现重复导致冲突。

## cwd

**类型**`string`

**默认值**`process.cwd()`

配置 `include``exclude` 的匹配上下文

## include

**类型**`string | string[]`

**默认值**
`['mock/**/*.mock.{js,ts,cjs,mjs,json,json5}']` 相对于根目录
`['mock/**/*.mock.{js,ts,cjs,mjs,json,json5}']` 相对于 [`cwd`](#cwd)

配置读取 mock文件,可以是一个 目录,glob,或者一个数组

Expand All @@ -84,7 +92,7 @@ interface MockServerPluginOptions {
**类型**`string | string[]`

**默认值**
`['**/node_modules/**','**/test/**','**/cypress/**','src/**','**/.vscode/**','**/.git/**','**/dist/**']`
`['**/node_modules/**','**/test/**','**/cypress/**','src/**','**/.vscode/**','**/.git/**','**/dist/**']` 相对于 [`cwd`](#cwd)

配置读取 mock文件时,需要排除的文件, 可以是一个 目录、glob、或者一个数组

Expand Down

0 comments on commit 3bea852

Please sign in to comment.