@@ -43,11 +43,9 @@ const appPackageJson = require(paths.appPackageJson);
4343// Source maps are resource heavy and can cause out of memory issue for large source files.
4444const shouldUseSourceMap = process . env . GENERATE_SOURCEMAP !== 'false' ;
4545
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+ ) ;
5149
5250// Some apps do not need the benefits of saving a web request, so not inlining the chunk
5351// makes for a smoother build process.
@@ -85,6 +83,8 @@ module.exports = function(webpackEnv) {
8583 // Get environment variables to inject into our app.
8684 const env = getClientEnvironment ( paths . publicUrlOrPath . slice ( 0 , - 1 ) ) ;
8785
86+ const shouldUseReactRefresh = env . raw . REACT_REFRESH ;
87+
8888 // common function to get style loaders
8989 const getStyleLoaders = ( cssOptions , preProcessor ) => {
9090 const loaders = [
@@ -168,7 +168,7 @@ module.exports = function(webpackEnv) {
168168 // the line below with these two lines if you prefer the stock client:
169169 // require.resolve('webpack-dev-server/client') + '?/',
170170 // require.resolve('webpack/hot/dev-server'),
171- isEnvDevelopment && webpackDevClientEntry ,
171+ isEnvDevelopment && ! shouldUseReactRefresh && webpackDevClientEntry ,
172172 // Finally, this is your app's code:
173173 paths . appIndexJs ,
174174 // We include the app code last so that if there is a runtime error during
@@ -620,7 +620,13 @@ module.exports = function(webpackEnv) {
620620 // Provide fast-refresh https://github.com/facebook/react/tree/master/packages/react-refresh
621621 isEnvDevelopment &&
622622 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+ } ) ,
624630 // Watcher doesn't work well if you mistype casing in a path so we use
625631 // a plugin that prints an error when you attempt to do this.
626632 // See https://github.com/facebook/create-react-app/issues/240
0 commit comments