diff --git a/packages/document/main-doc/docs/en/configure/app/output/disable-source-map.mdx b/packages/document/main-doc/docs/en/configure/app/output/disable-source-map.mdx index ebcb5195a31f..adf682a64469 100644 --- a/packages/document/main-doc/docs/en/configure/app/output/disable-source-map.mdx +++ b/packages/document/main-doc/docs/en/configure/app/output/disable-source-map.mdx @@ -26,44 +26,6 @@ const defaultDisableSourceMap = { Whether to disable Source Map generation. -:::tip What is a Source Map -Source Map is an information file that saves the source code mapping relationship. It records each location of the compiled code and the corresponding pre-compilation location. With Source Map, you can directly view the source code when debugging the compiled code. +:::warning +**Deprecated**: This configuration is deprecated, please use the boolean usage of `output.sourceMap` instead. ::: - -By default, Builder's Source Map generation rules are: - -- In development build, SourceMap of JS files and CSS files will be generated, which is convenient for debugging. -- In production build, the Source Map of JS files will be generated for debugging and troubleshooting online problems; the Source Map of CSS files will not be generated. - -If the project does not need Source Map, you can turned off it to speed up the compile speed. - -```js -export default { - output: { - disableSourceMap: true, - }, -}; -``` - -If you want to enable Source Map in development and disable it in the production, you can set to: - -```js -export default { - output: { - disableSourceMap: process.env.NODE_ENV === 'production', - }, -}; -``` - -If you need to individually control the Source Map of JS files or CSS files, you can refer to the following settings: - -```js -export default { - output: { - disableSourceMap: { - js: false, - css: true, - }, - }, -}; -``` diff --git a/packages/document/main-doc/docs/en/configure/app/output/source-map.mdx b/packages/document/main-doc/docs/en/configure/app/output/source-map.mdx new file mode 100644 index 000000000000..ea9466d8d327 --- /dev/null +++ b/packages/document/main-doc/docs/en/configure/app/output/source-map.mdx @@ -0,0 +1,30 @@ +--- +title: sourceMap +configName: output.sourceMap +--- + +# output.sourceMap + +- **Type:** + +```ts +type SourceMap = { + js?: Rspack.Configuration['devtool']; + css?: boolean; +}; +``` + +- **Default:** + +```ts +const defaultSourceMap = { + js: isDev ? 'cheap-module-source-map' : false, + css: false, +}; +``` + +Used to set whether to generate source map files, and which format of source map to generate. + +import RsbuildConig from '@site-docs-en/components/rsbuild-config-tooltip'; + + diff --git a/packages/document/main-doc/docs/en/configure/app/output/splitRouteChunks.mdx b/packages/document/main-doc/docs/en/configure/app/output/split-route-chunks.mdx similarity index 100% rename from packages/document/main-doc/docs/en/configure/app/output/splitRouteChunks.mdx rename to packages/document/main-doc/docs/en/configure/app/output/split-route-chunks.mdx diff --git a/packages/document/main-doc/docs/zh/configure/app/output/disable-source-map.mdx b/packages/document/main-doc/docs/zh/configure/app/output/disable-source-map.mdx index aaad3ee8b6c1..cbd0af0ed790 100644 --- a/packages/document/main-doc/docs/zh/configure/app/output/disable-source-map.mdx +++ b/packages/document/main-doc/docs/zh/configure/app/output/disable-source-map.mdx @@ -26,44 +26,6 @@ const defaultDisableSourceMap = { 是否禁用 Source Map 生成。 -:::tip 什么是 Source Map -Source Map 是保存源代码映射关系的信息文件,它记录了编译后的代码的每一个位置,以及所对应的编译前的位置。通过 Source Map,可以在调试编译后的代码时,直接查看对应的源代码。 +:::warning +**Deprecated**:该配置已废弃,请使用 `output.sourceMap` 的布尔用法代替。 ::: - -默认情况下,Builder 的 Source Map 生成规则如下: - -- 在开发环境构建时,会生成 JS 文件和 CSS 文件的 SourceMap,便于进行开发调试。 -- 在生产环境构建时,会生成 JS 文件的 Source Map,用于调试和排查线上问题;不会生成 CSS 文件的 Source Map。 - -如果项目不需要 Source Map,可以关闭该功能,从而提升构建的速度。 - -```js -export default { - output: { - disableSourceMap: true, - }, -}; -``` - -如果需要开启开发环境的 Source Map,并在生产环境禁用,可以设置为: - -```js -export default { - output: { - disableSourceMap: process.env.NODE_ENV === 'production', - }, -}; -``` - -如果需要单独控制 JS 文件或 CSS 文件的 Source Map,可以参考下方设置: - -```js -export default { - output: { - disableSourceMap: { - js: false, - css: true, - }, - }, -}; -``` diff --git a/packages/document/main-doc/docs/zh/configure/app/output/source-map.mdx b/packages/document/main-doc/docs/zh/configure/app/output/source-map.mdx new file mode 100644 index 000000000000..7f73b8b8269d --- /dev/null +++ b/packages/document/main-doc/docs/zh/configure/app/output/source-map.mdx @@ -0,0 +1,30 @@ +--- +title: sourceMap +configName: output.sourceMap +--- + +# output.sourceMap + +- **类型:** + +```ts +type SourceMap = { + js?: Rspack.Configuration['devtool']; + css?: boolean; +}; +``` + +- **默认值:** + +```ts +const defaultSourceMap = { + js: isDev ? 'cheap-module-source-map' : false, + css: false, +}; +``` + +用于设置是否生成 source map 文件,以及生成哪一种格式的 source map。 + +import RsbuildConig from '@site-docs/components/rsbuild-config-tooltip'; + + diff --git a/packages/document/main-doc/docs/zh/configure/app/output/splitRouteChunks.mdx b/packages/document/main-doc/docs/zh/configure/app/output/split-route-chunks.mdx similarity index 100% rename from packages/document/main-doc/docs/zh/configure/app/output/splitRouteChunks.mdx rename to packages/document/main-doc/docs/zh/configure/app/output/split-route-chunks.mdx