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:
Rsbuild 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, Rsbuild 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 dev.client
configuration.
The default config are as follows, Rsbuild 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 dev.client
to the following values so that HMR requests can reach the local Dev Server.
Please refer to HMR FAQ.