File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ verifyTypeScriptSetup();
3434const path = require ( 'path' ) ;
3535const chalk = require ( 'react-dev-utils/chalk' ) ;
3636const fs = require ( 'fs-extra' ) ;
37+ const bfj = require ( 'bfj' ) ;
3738const webpack = require ( 'webpack' ) ;
3839const configFactory = require ( '../config/webpack.config' ) ;
3940const 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
6367const 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}
You can’t perform that action at this time.
0 commit comments