File tree Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ process.env.NODE_ENV = 'production';
33
44require ( 'react-scripts/config/env' ) ;
55
6+ const patchModule = require ( './utils/cache' ) ;
7+
68const fs = require ( 'fs-extra' ) ;
79const path = require ( 'path' ) ;
810
@@ -14,12 +16,11 @@ const originalConfigFactory = require('react-scripts/config/webpack.config');
1416
1517if ( fs . existsSync ( webpackMonkeyPath ) ) {
1618 console . log ( chalk . yellow ( 'WARNING! You are using modified webpack config!' ) ) ;
17- const configPatch = require ( webpackMonkeyPath )
18- const configModule = require . cache [ require . resolve ( 'react-scripts/config/webpack.config' ) ] ;
19- configModule . exports = ( ...args ) => {
19+ const configPatch = require ( webpackMonkeyPath ) ;
20+ patchModule ( 'react-scripts/config/webpack.config' , ( ...args ) => {
2021 const webpackConfig = originalConfigFactory ( ...args ) ;
2122 return configPatch ( webpackConfig , false ) || webpackConfig ;
22- } ;
23+ } ) ;
2324}
2425
2526require ( 'react-scripts/scripts/build' ) ;
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ process.env.NODE_ENV = 'production';
33
44require ( 'react-scripts/config/env' ) ;
55
6+ const patchModule = require ( './utils/cache' ) ;
7+
68const fs = require ( 'fs-extra' ) ;
79const path = require ( 'path' ) ;
810
@@ -14,12 +16,11 @@ const originalConfigFactory = require('react-scripts/config/webpack.config');
1416
1517if ( fs . existsSync ( webpackMonkeyPath ) ) {
1618 console . log ( chalk . yellow ( 'WARNING! You are using modified webpack config!' ) ) ;
17- const configPatch = require ( webpackMonkeyPath )
18- const configModule = require . cache [ require . resolve ( 'react-scripts/config/webpack.config' ) ] ;
19- configModule . exports = ( ...args ) => {
19+ const configPatch = require ( webpackMonkeyPath ) ;
20+ patchModule ( 'react-scripts/config/webpack.config' , ( ...args ) => {
2021 const webpackConfig = originalConfigFactory ( ...args ) ;
2122 return configPatch ( webpackConfig , true ) || webpackConfig ;
22- } ;
23+ } ) ;
2324}
2425
2526require ( 'react-scripts/scripts/start' ) ;
Original file line number Diff line number Diff line change 1+ function patchModule ( key , value ) {
2+ const configModule = require . cache [ require . resolve ( key ) ] ;
3+ configModule . exports = value ;
4+ }
5+
6+ module . exports = patchModule ;
You can’t perform that action at this time.
0 commit comments