@@ -56,7 +56,7 @@ export function generateBundleStats(
56
56
}
57
57
}
58
58
59
- function generateBuildStatsTable ( data : BundleStats [ ] , colors : boolean ) : string {
59
+ function generateBuildStatsTable ( data : BundleStats [ ] , colors : boolean , showTotalSize : boolean ) : string {
60
60
const g = ( x : string ) => colors ? ansiColors . greenBright ( x ) : x ;
61
61
const c = ( x : string ) => colors ? ansiColors . cyanBright ( x ) : x ;
62
62
const bold = ( x : string ) => colors ? ansiColors . bold ( x ) : x ;
@@ -65,13 +65,27 @@ function generateBuildStatsTable(data: BundleStats[], colors: boolean): string {
65
65
const changedEntryChunksStats : BundleStatsData [ ] = [ ] ;
66
66
const changedLazyChunksStats : BundleStatsData [ ] = [ ] ;
67
67
68
+ let initialTotalSize = 0 ;
69
+
68
70
for ( const { initial, stats } of data ) {
69
71
const [ files , names , size ] = stats ;
70
- ( initial ? changedEntryChunksStats : changedLazyChunksStats ) . push ( [
72
+
73
+ const data : BundleStatsData = [
71
74
g ( files ) ,
72
75
names ,
73
- c ( typeof size === 'string' ? size : formatSize ( size ) ) ,
74
- ] ) ;
76
+ c ( typeof size === 'number' ? formatSize ( size ) : size ) ,
77
+ ] ;
78
+
79
+ if ( initial ) {
80
+ changedEntryChunksStats . push ( data ) ;
81
+
82
+ if ( typeof size === 'number' ) {
83
+ initialTotalSize += size ;
84
+ }
85
+
86
+ } else {
87
+ changedLazyChunksStats . push ( data ) ;
88
+ }
75
89
}
76
90
77
91
const bundleInfo : ( string | number ) [ ] [ ] = [ ] ;
@@ -82,6 +96,11 @@ function generateBuildStatsTable(data: BundleStats[], colors: boolean): string {
82
96
[ 'Initial Chunk Files' , 'Names' , 'Size' ] . map ( bold ) ,
83
97
...changedEntryChunksStats ,
84
98
) ;
99
+
100
+ if ( showTotalSize ) {
101
+ bundleInfo . push ( [ ] ) ;
102
+ bundleInfo . push ( [ ' ' , 'Initial Total' , formatSize ( initialTotalSize ) ] . map ( bold ) ) ;
103
+ }
85
104
}
86
105
87
106
// Seperator
@@ -100,6 +119,7 @@ function generateBuildStatsTable(data: BundleStats[], colors: boolean): string {
100
119
return textTable ( bundleInfo , {
101
120
hsep : dim ( ' | ' ) ,
102
121
stringLength : s => removeColor ( s ) . length ,
122
+ align : [ 'l' , 'l' , 'r' ] ,
103
123
} ) ;
104
124
}
105
125
@@ -132,15 +152,15 @@ function statsToString(json: any, statsConfig: any, bundleState?: BundleStats[])
132
152
if ( a . stats [ 2 ] > b . stats [ 2 ] ) {
133
153
return - 1 ;
134
154
}
135
-
155
+
136
156
if ( a . stats [ 2 ] < b . stats [ 2 ] ) {
137
157
return 1 ;
138
158
}
139
159
140
160
return 0 ;
141
161
} ) ;
142
162
143
- const statsTable = generateBuildStatsTable ( changedChunksStats , colors ) ;
163
+ const statsTable = generateBuildStatsTable ( changedChunksStats , colors , unchangedChunkNumber === 0 ) ;
144
164
145
165
// In some cases we do things outside of webpack context
146
166
// Such us index generation, service worker augmentation etc...
0 commit comments