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
9 changes: 6 additions & 3 deletions packages/core/src/cli/initConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
RslibConfig,
} from '../types';
import { getAbsolutePath } from '../utils/helper';
import { logger } from '../utils/logger';
import { isDebugKey, logger } from '../utils/logger';
import type { BuildOptions, CommonOptions } from './commands';
import { onBeforeRestart } from './restart';

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

applyCliOptions(config, options, root);

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

return {
config,
Expand Down
10 changes: 6 additions & 4 deletions packages/core/src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@
import { type Logger, logger } from 'rslog';
import { color } from './color';

export const isDebug = (): boolean => {
export const isDebugKey = (keys: string[]): boolean => {
if (!process.env.DEBUG) {
return false;
}

const values = process.env.DEBUG.toLocaleLowerCase().split(',');
return ['rslib', 'rsbuild', 'rs*', 'rstack', '*'].some((key) =>
values.includes(key),
);
return keys.some((key) => values.includes(key));
};

export const isDebug = (): boolean => {
return isDebugKey(['rslib', 'rsbuild', 'rs*', 'rstack', '*']);
};

// setup the logger level
Expand Down
2 changes: 1 addition & 1 deletion website/docs/en/guide/basic/configure-rslib.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,5 @@ Inspect config succeed, open following files to view the content:
- Open the generated `/dist/.rsbuild/rspack.config.esm.mjs` file to see the complete content of the Rspack config.

::: info
If you want to view the normalized Rslib configuration, you need to run [rslib inspect](/guide/basic/cli#rslib-inspect) command.
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.
:::
2 changes: 1 addition & 1 deletion website/docs/zh/guide/basic/configure-rslib.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,5 @@ Inspect config succeed, open following files to view the content:
- 打开生成的 `/dist/.rsbuild/rspack.config.esm.mjs` 文件,即可查看 Rspack 配置的完整内容。

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