Skip to content

Commit b974c30

Browse files
authored
fix: verbose Rslib normalized config only in Rslib debug mode (#1312)
1 parent da7ef34 commit b974c30

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

packages/core/src/cli/initConfig.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type {
88
RslibConfig,
99
} from '../types';
1010
import { getAbsolutePath } from '../utils/helper';
11-
import { logger } from '../utils/logger';
11+
import { isDebugKey, logger } from '../utils/logger';
1212
import type { BuildOptions, CommonOptions } from './commands';
1313
import { onBeforeRestart } from './restart';
1414

@@ -141,8 +141,11 @@ export async function initConfig(options: CommonOptions): Promise<{
141141

142142
applyCliOptions(config, options, root);
143143

144-
logger.debug('Rslib config used to generate Rsbuild environments:');
145-
logger.debug(`\n${util.inspect(config, { depth: null, colors: true })}`);
144+
// only debug serialized rslib config when DEBUG=rslib
145+
if (isDebugKey(['rslib'])) {
146+
logger.debug('Rslib config used to generate Rsbuild environments:');
147+
logger.debug(`\n${util.inspect(config, { depth: null, colors: true })}`);
148+
}
146149

147150
return {
148151
config,

packages/core/src/utils/logger.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@
1515
import { type Logger, logger } from 'rslog';
1616
import { color } from './color';
1717

18-
export const isDebug = (): boolean => {
18+
export const isDebugKey = (keys: string[]): boolean => {
1919
if (!process.env.DEBUG) {
2020
return false;
2121
}
2222

2323
const values = process.env.DEBUG.toLocaleLowerCase().split(',');
24-
return ['rslib', 'rsbuild', 'rs*', 'rstack', '*'].some((key) =>
25-
values.includes(key),
26-
);
24+
return keys.some((key) => values.includes(key));
25+
};
26+
27+
export const isDebug = (): boolean => {
28+
return isDebugKey(['rslib', 'rsbuild', 'rs*', 'rstack', '*']);
2729
};
2830

2931
// setup the logger level

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)