File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 48
48
"eslint-plugin-react" : " 5.2.2" ,
49
49
"extract-text-webpack-plugin" : " 1.0.1" ,
50
50
"file-loader" : " 0.9.0" ,
51
+ "filesize" : " ^3.3.0" ,
51
52
"fs-extra" : " 0.30.0" ,
52
53
"html-webpack-plugin" : " 2.22.0" ,
53
54
"json-loader" : " 0.5.4" ,
Original file line number Diff line number Diff line change 9
9
10
10
process . env . NODE_ENV = 'production' ;
11
11
12
+ var filesize = require ( 'filesize' ) ;
12
13
var rimrafSync = require ( 'rimraf' ) . sync ;
13
14
var webpack = require ( 'webpack' ) ;
14
15
var config = require ( '../config/webpack.config.prod' ) ;
@@ -18,6 +19,15 @@ var paths = require('../config/paths');
18
19
// if you're in it, you don't end up in Trash
19
20
rimrafSync ( paths . appBuild + '/*' ) ;
20
21
22
+ function logBuildSize ( assets , extension ) {
23
+ for ( var i = 0 ; i < assets . length ; i ++ ) {
24
+ var asset = assets [ i ] ;
25
+ if ( asset [ 'name' ] . endsWith ( extension ) ) {
26
+ console . log ( 'Size of ' + asset [ 'name' ] + ': ' + filesize ( asset [ 'size' ] ) ) ;
27
+ }
28
+ }
29
+ }
30
+
21
31
webpack ( config ) . run ( function ( err , stats ) {
22
32
if ( err ) {
23
33
console . error ( 'Failed to create a production build. Reason:' ) ;
@@ -48,6 +58,9 @@ webpack(config).run(function(err, stats) {
48
58
console . log ( ' hs' ) ;
49
59
console . log ( ' ' + openCommand + ' http://localhost:8080' ) ;
50
60
console . log ( ) ;
61
+ var assets = stats . toJson ( ) [ 'assets' ] ;
62
+ logBuildSize ( assets , '.js' ) ;
63
+ logBuildSize ( assets , '.css' ) ;
51
64
}
52
65
console . log ( 'The bundle is optimized and ready to be deployed to production.' ) ;
53
66
} ) ;
You can’t perform that action at this time.
0 commit comments