Hot Module Replacement (HMR) exchanges, adds, or removes modules while an application is running, without a full reload. This can significantly speed up development in a few ways:
Builder has built-in support for HMR. By default, HMR is enabled in development.
By setting dev.hmr to false, HMR can be disabled, which the HMR and react-refresh will no longer work.
By default, Builder uses the host and port number of the current page to splice the WebSocket URL of HMR.
When the HMR connection fails, you can specify the WebSocket URL by customizing devServer.client
configuration.
The default config are as follows, Builder will automatically deduce the URL of the WebSocket request according to the current location:
If you are proxying an online page to local development, WebSocket requests will fail to connect. You can try configuring devServer.client
to the following values so that HMR requests can reach the local Dev Server.
window.location.reload()
.DevServer provides two configuration options, hot and liveReload, to control how updates are made. When both hot and liveReload are open, DevServer will attempt to use hot mode (HMR) first, and will degrade to reloading the page if the HMR update fails.
Please refer to HMR FAQ.