File tree Expand file tree Collapse file tree 2 files changed +25
-11
lines changed Expand file tree Collapse file tree 2 files changed +25
-11
lines changed Original file line number Diff line number Diff line change 11process . env . BABEL_ENV = 'production' ;
22process . env . NODE_ENV = 'production' ;
33
4+ require ( 'react-scripts/config/env' ) ;
5+
46const fs = require ( 'fs-extra' ) ;
57const path = require ( 'path' ) ;
68
7- require ( 'react-scripts/config/env' ) ;
8-
99const chalk = require ( 'chalk' ) ;
1010const appPath = require ( 'react-scripts/config/paths' ) . appPath ;
1111const webpackMonkeyPath = path . resolve ( appPath , 'webpack.monkey.js' ) ;
12- const webpackConfig = require ( 'react-scripts/config/webpack.config.prod' ) ;
12+
13+ const originalConfigFactory = require ( 'react-scripts/config/webpack.config' ) ;
1314
1415if ( fs . existsSync ( webpackMonkeyPath ) ) {
1516 console . log ( chalk . yellow ( 'WARNING! You are using modified webpack config!' ) ) ;
16- require ( webpackMonkeyPath ) ( webpackConfig , false ) ;
17+ const configPatch = require ( webpackMonkeyPath )
18+ const configModule = require . cache [ require . resolve ( 'react-scripts/config/webpack.config' ) ] ;
19+ configModule . exports = ( ...args ) => {
20+ const webpackConfig = originalConfigFactory ( ...args ) ;
21+ return configPatch ( webpackConfig , false ) || webpackConfig ;
22+ } ;
1723}
24+
1825require ( 'react-scripts/scripts/build' ) ;
Original file line number Diff line number Diff line change 1- process . env . BABEL_ENV = 'development' ;
2- process . env . NODE_ENV = 'development' ;
3-
4- const fs = require ( 'fs' ) ;
5- const path = require ( 'path' ) ;
1+ process . env . BABEL_ENV = 'production' ;
2+ process . env . NODE_ENV = 'production' ;
63
74require ( 'react-scripts/config/env' ) ;
85
6+ const fs = require ( 'fs-extra' ) ;
7+ const path = require ( 'path' ) ;
8+
99const chalk = require ( 'chalk' ) ;
1010const appPath = require ( 'react-scripts/config/paths' ) . appPath ;
1111const webpackMonkeyPath = path . resolve ( appPath , 'webpack.monkey.js' ) ;
12- const webpackConfig = require ( 'react-scripts/config/webpack.config.dev' ) ;
12+
13+ const originalConfigFactory = require ( 'react-scripts/config/webpack.config' ) ;
1314
1415if ( fs . existsSync ( webpackMonkeyPath ) ) {
1516 console . log ( chalk . yellow ( 'WARNING! You are using modified webpack config!' ) ) ;
16- require ( webpackMonkeyPath ) ( webpackConfig , true ) ;
17+ const configPatch = require ( webpackMonkeyPath )
18+ const configModule = require . cache [ require . resolve ( 'react-scripts/config/webpack.config' ) ] ;
19+ configModule . exports = ( ...args ) => {
20+ const webpackConfig = originalConfigFactory ( ...args ) ;
21+ return configPatch ( webpackConfig , true ) || webpackConfig ;
22+ } ;
1723}
24+
1825require ( 'react-scripts/scripts/start' ) ;
You can’t perform that action at this time.
0 commit comments