@@ -43,11 +43,9 @@ const appPackageJson = require(paths.appPackageJson);
43
43
// Source maps are resource heavy and can cause out of memory issue for large source files.
44
44
const shouldUseSourceMap = process . env . GENERATE_SOURCEMAP !== 'false' ;
45
45
46
- // React refresh isn't 100% stable right now. We have a feature flag to enable it.
47
- const shouldUseReactRefresh = process . env . REACT_REFRESH === 'true' ;
48
- const webpackDevClientEntry = shouldUseReactRefresh
49
- ? require . resolve ( 'react-dev-utils/webpackFastRefreshDevClient' )
50
- : require . resolve ( 'react-dev-utils/webpackHotDevClient' ) ;
46
+ const webpackDevClientEntry = require . resolve (
47
+ 'react-dev-utils/webpackHotDevClient'
48
+ ) ;
51
49
52
50
// Some apps do not need the benefits of saving a web request, so not inlining the chunk
53
51
// makes for a smoother build process.
@@ -85,6 +83,8 @@ module.exports = function(webpackEnv) {
85
83
// Get environment variables to inject into our app.
86
84
const env = getClientEnvironment ( paths . publicUrlOrPath . slice ( 0 , - 1 ) ) ;
87
85
86
+ const shouldUseReactRefresh = env . raw . REACT_REFRESH ;
87
+
88
88
// common function to get style loaders
89
89
const getStyleLoaders = ( cssOptions , preProcessor ) => {
90
90
const loaders = [
@@ -168,7 +168,7 @@ module.exports = function(webpackEnv) {
168
168
// the line below with these two lines if you prefer the stock client:
169
169
// require.resolve('webpack-dev-server/client') + '?/',
170
170
// require.resolve('webpack/hot/dev-server'),
171
- isEnvDevelopment && webpackDevClientEntry ,
171
+ isEnvDevelopment && ! shouldUseReactRefresh && webpackDevClientEntry ,
172
172
// Finally, this is your app's code:
173
173
paths . appIndexJs ,
174
174
// We include the app code last so that if there is a runtime error during
@@ -620,7 +620,13 @@ module.exports = function(webpackEnv) {
620
620
// Provide fast-refresh https://github.com/facebook/react/tree/master/packages/react-refresh
621
621
isEnvDevelopment &&
622
622
shouldUseReactRefresh &&
623
- new ReactRefreshWebpackPlugin ( { disableRefreshCheck : true } ) ,
623
+ new ReactRefreshWebpackPlugin ( {
624
+ disableRefreshCheck : true ,
625
+ overlay : {
626
+ entry : webpackDevClientEntry ,
627
+ module : require . resolve ( 'react-dev-utils/errorOverlayModuleEntry' ) ,
628
+ } ,
629
+ } ) ,
624
630
// Watcher doesn't work well if you mistype casing in a path so we use
625
631
// a plugin that prints an error when you attempt to do this.
626
632
// See https://github.com/facebook/create-react-app/issues/240
0 commit comments