Skip to content

Commit

Permalink
Add back in --stats output from webpack. (#8790)
Browse files Browse the repository at this point in the history
  • Loading branch information
samccone committed May 5, 2020
1 parent 6a7aaa2 commit 408c065
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"babel-loader": "8.1.0",
"babel-plugin-named-asset-import": "^0.3.6",
"babel-preset-react-app": "^9.1.2",
"bfj": "^7.0.2",
"camelcase": "^5.3.1",
"case-sensitive-paths-webpack-plugin": "2.3.0",
"css-loader": "3.5.3",
Expand Down
17 changes: 15 additions & 2 deletions packages/react-scripts/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ verifyTypeScriptSetup();
const path = require('path');
const chalk = require('react-dev-utils/chalk');
const fs = require('fs-extra');
const bfj = require('bfj');
const webpack = require('webpack');
const configFactory = require('../config/webpack.config');
const paths = require('../config/paths');
Expand All @@ -59,6 +60,9 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
process.exit(1);
}

const argv = process.argv.slice(2);
const writeStatsJson = argv.indexOf('--stats') !== -1;

// Generate configuration
const config = configFactory('production');

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

return resolve({
const resolveArgs = {
stats,
previousFileSizes,
warnings: messages.warnings,
});
};

if (writeStatsJson) {
return bfj
.write(paths.appBuild + '/bundle-stats.json', stats.toJson())
.then(() => resolve(resolveArgs))
.catch(error => reject(new Error(error)));
}

return resolve(resolveArgs);
});
});
}
Expand Down

0 comments on commit 408c065

Please sign in to comment.