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
2 changes: 1 addition & 1 deletion packages/core/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,7 @@ export type WriteToDisk = boolean | ((filename: string) => boolean);

export interface DevConfig {
/**
* Enables forwarding of browser runtime errors to the terminal. When `true`, the dev
* Controls whether to forward browser runtime errors to the terminal. When `true`, the dev
* 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]`).
* @default true
Expand Down
38 changes: 38 additions & 0 deletions website/docs/en/config/dev/browser-logs.mdx
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)
Comment thread
chenjiahan marked this conversation as resolved.
```

## Disabling

Set `dev.browserLogs` to `false` to disable this behavior.

```ts title="rsbuild.config.ts"
export default {
dev: {
browserLogs: false,
},
};
```
38 changes: 38 additions & 0 deletions website/docs/zh/config/dev/browser-logs.mdx
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)
Comment thread
chenjiahan marked this conversation as resolved.
```

## 禁用

将 `dev.browserLogs` 设置为 `false` 可以禁用此行为。

```ts title="rsbuild.config.ts"
export default {
dev: {
browserLogs: false,
},
};
```
Loading