Skip to content

Commit ecb3011

Browse files
authored
docs: add reading jsconfig.json guide (#2038)
1 parent 862ee40 commit ecb3011

File tree

2 files changed

+28
-0
lines changed
  • packages/document/docs

2 files changed

+28
-0
lines changed

packages/document/docs/en/guide/migration/cra.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,20 @@ In the Rsbuild project, you can remove the dependency and code related to react-
229229

230230
You can read [Browser Compatibility](/guide/advanced/browser-compatibility) to understand how Rsbuild handles polyfills.
231231

232+
## Reading jsconfig.json
233+
234+
In non-TypeScript projects, CRA supports reading the `paths` field in jsconfig.json as the path alias.
235+
236+
If you want to use this feature in Rsbuild, you can set the [source.tsconfigPath](/config/source/tsconfig-path) option, so that Rsbuild can recognize the `paths` field in jsconfig.json.
237+
238+
```js title="rsbuild.config.mjs"
239+
export default {
240+
source: {
241+
tsconfigPath: './jsconfig.json',
242+
},
243+
};
244+
```
245+
232246
## CRACO Migration
233247

234248
If your project is using [CRACO](https://craco.js.org) to override CRA configuration, you can refer to the table below for migration:

packages/document/docs/zh/guide/migration/cra.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,20 @@ CRA 提供了 [react-app-polyfill](https://www.npmjs.com/package/react-app-polyf
229229

230230
你可以参考 [浏览器兼容性](/guide/advanced/browser-compatibility) 来了解 Rsbuild 是如何处理 polyfill 的。
231231

232+
## 读取 jsconfig.json
233+
234+
在非 TypeScript 项目中,CRA 支持读取 jsconfig.json 中的 `paths` 字段作为路径别名。
235+
236+
如果你需要在 Rsbuild 中使用该特性,可以使用 [source.tsconfigPath](/config/source/tsconfig-path) 选项,使 Rsbuild 能够识别 jsconfig.json 中的 `paths` 字段。
237+
238+
```js title="rsbuild.config.mjs"
239+
export default {
240+
source: {
241+
tsconfigPath: './jsconfig.json',
242+
},
243+
};
244+
```
245+
232246
## CRACO 迁移
233247

234248
如果你的项目使用了 [CRACO](https://craco.js.org) 来覆盖 CRA 的配置,可以参考下表来迁移:

0 commit comments

Comments
 (0)