Skip to content

Commit 52a8605

Browse files
lvwrenceLawrence Wu
authored andcommitted
Print gzipped filesize, address nits
1 parent e2f4aa9 commit 52a8605

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
"eslint-plugin-react": "5.2.2",
4949
"extract-text-webpack-plugin": "1.0.1",
5050
"file-loader": "0.9.0",
51-
"filesize": "^3.3.0",
5251
"fs-extra": "0.30.0",
52+
"gzip-size": "^3.0.0",
5353
"html-webpack-plugin": "2.22.0",
5454
"json-loader": "0.5.4",
5555
"opn": "4.0.2",

scripts/build.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
process.env.NODE_ENV = 'production';
1111

12-
var filesize = require('filesize');
12+
var fs = require('fs');
13+
var gzipSize = require('gzip-size');
1314
var rimrafSync = require('rimraf').sync;
1415
var webpack = require('webpack');
1516
var config = require('../config/webpack.config.prod');
@@ -22,8 +23,9 @@ rimrafSync(paths.appBuild + '/*');
2223
function logBuildSize(assets, extension) {
2324
for (var i = 0; i < assets.length; i++) {
2425
var asset = assets[i];
25-
if (asset['name'].endsWith(extension)) {
26-
console.log('Size of ' + asset['name'] + ': ' + filesize(asset['size']));
26+
if (asset.name.endsWith('.' + extension)) {
27+
var fileContents = fs.readFileSync(paths.appBuild + '/' + asset.name);
28+
console.log('Size (gzipped) of ' + asset.name + ': ' + gzipSize.sync(fileContents));
2729
}
2830
}
2931
}
@@ -59,8 +61,8 @@ webpack(config).run(function(err, stats) {
5961
console.log(' ' + openCommand + ' http://localhost:8080');
6062
console.log();
6163
var assets = stats.toJson()['assets'];
62-
logBuildSize(assets, '.js');
63-
logBuildSize(assets, '.css');
64+
logBuildSize(assets, 'js');
65+
logBuildSize(assets, 'css');
6466
}
6567
console.log('The bundle is optimized and ready to be deployed to production.');
6668
});

0 commit comments

Comments
 (0)