File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 1
1
const buildJsBundle = require ( './build-js-bundle' ) ;
2
2
const outputCheckSize = require ( './check-size' ) ;
3
3
4
+ function output ( value , label = '' ) {
5
+ return `difference ${ label } : ${ value > 0 ? `+${ value } ` : value } bytes` ;
6
+ }
7
+
4
8
( async ( ) => {
5
9
process . env . NODE_ENV = 'production' ;
6
10
const first = outputCheckSize ( ) ;
7
11
await buildJsBundle ( ) ;
8
12
const second = outputCheckSize ( ) ;
9
13
10
- const difference = second - first ;
11
- console . log ( `difference: ${ difference > 0 ? `+ ${ difference } ` : difference } bytes` ) ;
14
+ console . log ( output ( second . size - first . size ) ) ;
15
+ console . log ( output ( second . gzippedSize - first . gzippedSize ) , 'gzipped' ) ;
12
16
} ) ( ) ;
Original file line number Diff line number Diff line change @@ -11,12 +11,15 @@ module.exports = () => {
11
11
const filePath = path . join ( __dirname , '../package/' , name ) ;
12
12
if ( fs . existsSync ( filePath ) ) {
13
13
const gzippedSize = gzipSize . fileSync ( filePath ) ;
14
- // const size = gzipSize.fileSync (filePath);
15
- console . log ( `${ name } : ${ gzippedSize } bytes ( gziped)` ) ;
16
- return gzippedSize ;
14
+ const { size } = fs . statSync ( filePath ) ;
15
+ console . log ( `${ name } : ${ size } ( ${ gzippedSize } gziped) bytes ` ) ;
16
+ return { gzippedSize, size } ;
17
17
}
18
18
console . log ( `${ filePath } not exists` ) ;
19
19
return 0 ;
20
20
} )
21
- . reduce ( ( total , num ) => total + num ) ;
21
+ . reduce ( ( total , num ) => ( {
22
+ gzippedSize : total . gzippedSize + num . gzippedSize ,
23
+ size : total . size + num . size ,
24
+ } ) ) ;
22
25
} ;
You can’t perform that action at this time.
0 commit comments