-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support dev.client configuration (#5678)
- Loading branch information
Showing
6 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@modern-js/uni-builder': patch | ||
--- | ||
|
||
feat: support dev.client configuration | ||
|
||
feat: 支持 dev.client 配置项 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
packages/document/main-doc/docs/en/configure/app/dev/client.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
sidebar_label: client | ||
--- | ||
|
||
# dev.client | ||
|
||
Configure the client code injected by Modern.js during the development process. This can be used to set the WebSocket URL for HMR. | ||
|
||
- **Type:** | ||
|
||
```ts | ||
type Client = { | ||
/** Specify the protocol name for the WebSocket request */ | ||
protocol?: 'ws' | 'wss'; | ||
/** Specify the path for the WebSocket request */ | ||
path?: string; | ||
/** Specify the port number for the WebSocket request */ | ||
port?: string; | ||
/** Specify the host for the WebSocket request */ | ||
host?: string; | ||
/** | ||
* Shows overlay in the browser when there are compiler errors | ||
* This feature requires the current browser version to support [Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components) | ||
*/ | ||
overlay?: boolean; | ||
}; | ||
``` | ||
|
||
- **Default:** | ||
|
||
```js | ||
const defaultConfig = { | ||
path: '/webpack-hmr', | ||
// Defaults to the port number of the dev server | ||
port: '', | ||
host: location.hostname, | ||
protocol: location.protocol === 'https:' ? 'wss' : 'ws', | ||
overlay: false, | ||
}; | ||
``` | ||
|
||
For detailed usage, please refer to [Rsbuild - dev.client](https://rsbuild.dev/config/dev/client). |
42 changes: 42 additions & 0 deletions
42
packages/document/main-doc/docs/zh/configure/app/dev/client.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
sidebar_label: client | ||
--- | ||
|
||
# dev.client | ||
|
||
配置 Modern.js 在开发过程中注入的 client 代码,可以用于设置热更新对应的 WebSocket URL。 | ||
|
||
- **类型:** | ||
|
||
```ts | ||
type Client = { | ||
/** 指定 WebSocket 请求的协议名称 */ | ||
protocol?: 'ws' | 'wss'; | ||
/** 指定 WebSocket 请求的路径 */ | ||
path?: string; | ||
/** 指定 WebSocket 请求的端口号 */ | ||
port?: string; | ||
/** 指定 WebSocket 请求的 host */ | ||
host?: string; | ||
/** | ||
* 当出现编译错误时,在浏览器中显示遮盖 | ||
* 该功能需要当前浏览器版本支持 [Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components) | ||
*/ | ||
overlay?: boolean; | ||
}; | ||
``` | ||
|
||
- **默认值:** | ||
|
||
```js | ||
const defaultConfig = { | ||
path: '/webpack-hmr', | ||
// 默认为开发服务器的端口号 | ||
port: '', | ||
host: location.hostname, | ||
protocol: location.protocol === 'https:' ? 'wss' : 'ws', | ||
overlay: true, | ||
}; | ||
``` | ||
|
||
详细用法可参考 [Rsbuild - dev.client](https://rsbuild.dev/zh/config/dev/client)。 |