Skip to content

Commit 7573196

Browse files
authored
feat: do not print detailed file size in bundleless mode (#1191)
1 parent 3c6aa04 commit 7573196

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

packages/core/src/config.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,39 @@ export function composeDecoratorsConfig(
502502
};
503503
}
504504

505+
export function composePrintFileSizeConfig(
506+
bundle: LibConfig['bundle'],
507+
target: RsbuildConfigOutputTarget,
508+
): EnvironmentConfig {
509+
if (bundle) {
510+
return {};
511+
}
512+
513+
// do not need to print detailed file size in bundleless mode
514+
return {
515+
performance: {
516+
printFileSize: {
517+
total: ({
518+
environmentName,
519+
distPath,
520+
assets,
521+
totalSize,
522+
totalGzipSize,
523+
}) => {
524+
let log = `${color.yellow(assets.length)} files generated in ${color.blue(distPath)} ${color.dim(`(${environmentName})`)}`;
525+
log += '\n';
526+
log += `${color.magenta('Total size:')} ${(totalSize / 1000).toFixed(1)} kB`;
527+
if (target === 'web') {
528+
log += ` ${color.green(`(${(totalGzipSize / 1000).toFixed(1)} kB gzipped)`)}`;
529+
}
530+
return log;
531+
},
532+
detail: false,
533+
},
534+
},
535+
};
536+
}
537+
505538
export async function createConstantRsbuildConfig(): Promise<EnvironmentConfig> {
506539
// When the default configuration is inconsistent with rsbuild, remember to modify the type hints
507540
// see https://github.com/web-infra-dev/rslib/discussions/856
@@ -1633,6 +1666,7 @@ async function composeLibRsbuildConfig(
16331666
compilerOptions,
16341667
config.source?.decorators?.version,
16351668
);
1669+
const printFileSizeConfig = composePrintFileSizeConfig(bundle, target);
16361670

16371671
return mergeRsbuildConfig(
16381672
formatConfig,
@@ -1662,6 +1696,7 @@ async function composeLibRsbuildConfig(
16621696
dtsConfig,
16631697
bannerFooterConfig,
16641698
decoratorsConfig,
1699+
printFileSizeConfig,
16651700
);
16661701
}
16671702

0 commit comments

Comments
 (0)