Skip to content

Commit 408c065

Browse files
authored
Add back in --stats output from webpack. (facebook#8790)
1 parent 6a7aaa2 commit 408c065

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

packages/react-scripts/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"babel-loader": "8.1.0",
3939
"babel-plugin-named-asset-import": "^0.3.6",
4040
"babel-preset-react-app": "^9.1.2",
41+
"bfj": "^7.0.2",
4142
"camelcase": "^5.3.1",
4243
"case-sensitive-paths-webpack-plugin": "2.3.0",
4344
"css-loader": "3.5.3",

packages/react-scripts/scripts/build.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ verifyTypeScriptSetup();
3434
const path = require('path');
3535
const chalk = require('react-dev-utils/chalk');
3636
const fs = require('fs-extra');
37+
const bfj = require('bfj');
3738
const webpack = require('webpack');
3839
const configFactory = require('../config/webpack.config');
3940
const paths = require('../config/paths');
@@ -59,6 +60,9 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
5960
process.exit(1);
6061
}
6162

63+
const argv = process.argv.slice(2);
64+
const writeStatsJson = argv.indexOf('--stats') !== -1;
65+
6266
// Generate configuration
6367
const config = configFactory('production');
6468

@@ -210,11 +214,20 @@ function build(previousFileSizes) {
210214
return reject(new Error(messages.warnings.join('\n\n')));
211215
}
212216

213-
return resolve({
217+
const resolveArgs = {
214218
stats,
215219
previousFileSizes,
216220
warnings: messages.warnings,
217-
});
221+
};
222+
223+
if (writeStatsJson) {
224+
return bfj
225+
.write(paths.appBuild + '/bundle-stats.json', stats.toJson())
226+
.then(() => resolve(resolveArgs))
227+
.catch(error => reject(new Error(error)));
228+
}
229+
230+
return resolve(resolveArgs);
218231
});
219232
});
220233
}

0 commit comments

Comments
 (0)