Skip to content

Commit 51fb323

Browse files
committed
fix: verbose Rslib normalized config only in Rslib debug mode
1 parent 8bb2dcd commit 51fb323

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

packages/core/src/cli/initConfig.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ import { logger } from '../utils/logger';
1212
import type { BuildOptions, CommonOptions } from './commands';
1313
import { onBeforeRestart } from './restart';
1414

15+
const shouldPrintSerializedRslibConfig = (): boolean => {
16+
if (!process.env.DEBUG) {
17+
return false;
18+
}
19+
20+
const values = process.env.DEBUG.toLocaleLowerCase().split(',');
21+
return ['rslib'].some((key) => values.includes(key));
22+
};
23+
1524
const getEnvDir = (cwd: string, envDir?: string) => {
1625
if (envDir) {
1726
return path.isAbsolute(envDir) ? envDir : path.resolve(cwd, envDir);
@@ -141,8 +150,11 @@ export async function initConfig(options: CommonOptions): Promise<{
141150

142151
applyCliOptions(config, options, root);
143152

144-
logger.debug('Rslib config used to generate Rsbuild environments:');
145-
logger.debug(`\n${util.inspect(config, { depth: null, colors: true })}`);
153+
// only debug serialized rslib config when DEBUG=rslib
154+
if (shouldPrintSerializedRslibConfig()) {
155+
logger.debug('Rslib config used to generate Rsbuild environments:');
156+
logger.debug(`\n${util.inspect(config, { depth: null, colors: true })}`);
157+
}
146158

147159
return {
148160
config,

website/docs/en/guide/basic/configure-rslib.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,5 +228,5 @@ Inspect config succeed, open following files to view the content:
228228
- Open the generated `/dist/.rsbuild/rspack.config.esm.mjs` file to see the complete content of the Rspack config.
229229

230230
::: info
231-
If you want to view the normalized Rslib configuration, you need to run [rslib inspect](/guide/basic/cli#rslib-inspect) command.
231+
If you want to view the normalized Rslib configuration, you can add the `DEBUG=rslib` environment variable when building or run the [rslib inspect](/guide/basic/cli#rslib-inspect) command.
232232
:::

website/docs/zh/guide/basic/configure-rslib.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,5 +228,5 @@ Inspect config succeed, open following files to view the content:
228228
- 打开生成的 `/dist/.rsbuild/rspack.config.esm.mjs` 文件,即可查看 Rspack 配置的完整内容。
229229

230230
::: info
231-
如果你想查看归一化后的 Rslib 配置,需要运行 [rslib inspect](/guide/basic/cli#rslib-inspect) 命令。
231+
如果你想查看归一化后的 Rslib 配置,可以在执行构建时添加 `DEBUG=rslib` 环境变量或运行 [rslib inspect](/guide/basic/cli#rslib-inspect) 命令。
232232
:::

0 commit comments

Comments
 (0)