File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff 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' ) } : ${ color . cyan ( ( 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+
505538export 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
You can’t perform that action at this time.
0 commit comments