File tree 2 files changed +16
-2
lines changed
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 38
38
"babel-loader" : " 8.1.0" ,
39
39
"babel-plugin-named-asset-import" : " ^0.3.6" ,
40
40
"babel-preset-react-app" : " ^9.1.2" ,
41
+ "bfj" : " ^7.0.2" ,
41
42
"camelcase" : " ^5.3.1" ,
42
43
"case-sensitive-paths-webpack-plugin" : " 2.3.0" ,
43
44
"css-loader" : " 3.5.3" ,
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ verifyTypeScriptSetup();
34
34
const path = require ( 'path' ) ;
35
35
const chalk = require ( 'react-dev-utils/chalk' ) ;
36
36
const fs = require ( 'fs-extra' ) ;
37
+ const bfj = require ( 'bfj' ) ;
37
38
const webpack = require ( 'webpack' ) ;
38
39
const configFactory = require ( '../config/webpack.config' ) ;
39
40
const paths = require ( '../config/paths' ) ;
@@ -59,6 +60,9 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
59
60
process . exit ( 1 ) ;
60
61
}
61
62
63
+ const argv = process . argv . slice ( 2 ) ;
64
+ const writeStatsJson = argv . indexOf ( '--stats' ) !== - 1 ;
65
+
62
66
// Generate configuration
63
67
const config = configFactory ( 'production' ) ;
64
68
@@ -210,11 +214,20 @@ function build(previousFileSizes) {
210
214
return reject ( new Error ( messages . warnings . join ( '\n\n' ) ) ) ;
211
215
}
212
216
213
- return resolve ( {
217
+ const resolveArgs = {
214
218
stats,
215
219
previousFileSizes,
216
220
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 ) ;
218
231
} ) ;
219
232
} ) ;
220
233
}
You can’t perform that action at this time.
0 commit comments