Skip to content

Add step to generate stats.json file #1464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/react-scripts/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@ function printFileSizes(stats, previousSizeMap) {
});
}

// Generate stats.json file
function generateStatsFile(stats, config) {
const statsFilepath = path.join(config.output.path, 'stats.json');

fs.writeFileSync(
statsFilepath,
JSON.stringify(stats.toJson("verbose"))
);
console.log('Stats file output to', chalk.cyan(path.join('build', 'stats.json')));
console.log('Open ', chalk.magenta('http://webpack.github.io/analyse/'), ' in your browser and upload the stats.json file!');
console.log(chalk.blue('(Tip: ', chalk.italic('CMD + double-click'), ' the link!)'));
console.log();
}

// Print out errors
function printErrors(summary, errors) {
console.log(chalk.red(summary));
Expand Down Expand Up @@ -155,6 +169,7 @@ function build(previousSizeMap) {
console.log();
printFileSizes(stats, previousSizeMap);
console.log();
generateStatsFile(stats, config);

var openCommand = process.platform === 'win32' ? 'start' : 'open';
var appPackage = require(paths.appPackageJson);
Expand Down