-
-
Notifications
You must be signed in to change notification settings - Fork 273
docs: add dev.browserLogs config #6287
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,38 @@ | ||
| # dev.browserLogs | ||
|
|
||
| - **Type:** `boolean` | ||
| - **Default:** `true` | ||
| - **Version:** Added in v1.5.13 | ||
|
|
||
| Controls whether to forward browser runtime errors to the terminal. | ||
|
|
||
| When `true`, the Rsbuild client listens for window `error` events in the browser and send them to the dev server, where they are printed in the terminal (prefixed with `[browser]`). | ||
|
|
||
| ## Example | ||
|
|
||
| For example, if you have the following code in your application: | ||
|
|
||
| ```jsx title="src/App.jsx" | ||
| const App = () => { | ||
| const item = undefined; | ||
| return <div>{item.name}</div>; | ||
| }; | ||
| ``` | ||
|
|
||
| The browser will throw an error, and Rsbuild will forward this error to the terminal: | ||
|
|
||
| ```bash | ||
| error [browser] Uncaught TypeError: Cannot read properties of undefined (reading 'name') (src/App.jsx:3:0) | ||
| ``` | ||
|
|
||
| ## Disabling | ||
|
|
||
| Set `dev.browserLogs` to `false` to disable this behavior. | ||
|
|
||
| ```ts title="rsbuild.config.ts" | ||
| export default { | ||
| dev: { | ||
| browserLogs: false, | ||
| }, | ||
| }; | ||
| ``` | ||
This file contains hidden or 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,38 @@ | ||
| # dev.browserLogs | ||
|
|
||
| - **类型:** `boolean` | ||
| - **默认值:** `true` | ||
| - **版本:** 新增于 v1.5.13 | ||
|
|
||
| 控制是否将浏览器运行时错误转发到终端。 | ||
|
|
||
| 当设置为 `true` 时,Rsbuild 的客户端会监听浏览器中的 window `error` 事件,并将它们发送到开发服务器,然后在终端中打印(带有 `[browser]` 为前缀)。 | ||
|
|
||
| ## 示例 | ||
|
|
||
| 例如,如果你的应用中有以下代码: | ||
|
|
||
| ```jsx title="src/App.jsx" | ||
| const App = () => { | ||
| const item = undefined; | ||
| return <div>{item.name}</div>; | ||
| }; | ||
| ``` | ||
|
|
||
| 浏览器会抛出错误,Rsbuild 会将此错误转发到终端: | ||
|
|
||
| ```bash | ||
| error [browser] Uncaught TypeError: Cannot read properties of undefined (reading 'name') (src/App.jsx:3:0) | ||
|
chenjiahan marked this conversation as resolved.
|
||
| ``` | ||
|
|
||
| ## 禁用 | ||
|
|
||
| 将 `dev.browserLogs` 设置为 `false` 可以禁用此行为。 | ||
|
|
||
| ```ts title="rsbuild.config.ts" | ||
| export default { | ||
| dev: { | ||
| browserLogs: false, | ||
| }, | ||
| }; | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.