close
logologo
Guide
Config
Plugin
API
Community
Version
Changelog
Rsbuild 0.x Doc
English
简体中文
Guide
Config
Plugin
API
Community
Changelog
Rsbuild 0.x Doc
English
简体中文
logologo

Getting Started

Introduction
Quick start
Features
Glossary

Framework

React
Vue
Preact
Svelte
Solid

Basic

CLI
Dev server
Output files
Static assets
HTML
JSON
Wasm
TypeScript
Web Workers
Deploy static site
Upgrade Rsbuild

Configuration

Configure Rspack
Configure Rsbuild
Configure SWC

Styling

CSS
CSS Modules
CSS-in-JS
Tailwind CSS v4
Tailwind CSS v3
UnoCSS

Advanced

Path aliases
Environment variables
Hot module replacement
Browserslist
Browser compatibility
Module Federation
Multi-environment builds
Server-side rendering (SSR)
Testing

Optimization

Code splitting
Bundle size optimization
Improve build performance
Inline static assets

Migration

Migrating from Rsbuild 0.x
webpack
Create React App
Vue CLI
Vite
Vite plugin
Modern.js Builder

Debug

Debug mode
Build profiling
Use Rsdoctor

FAQ

General FAQ
Features FAQ
Exceptions FAQ
HMR FAQ
📝 Edit this page on GitHub
Previous PageEnvironment variables
Next PageBrowserslist

#Hot module replacement

Hot Module Replacement (HMR) exchanges, adds, or removes modules while an application runs, without a full reload. This significantly speeds up development in several ways:

  • Retain application state that is lost during a full reload.
  • Save valuable development time by updating only what changed.
  • Instantly update the browser when modifying CSS / JS in source code, almost comparable to changing styles directly in the browser's dev tools.

#HMR toggle

Rsbuild has built-in support for HMR, which is enabled by default in development mode.

If you don't need HMR, set dev.hmr to false. This disables HMR and React Refresh, and Rsbuild automatically falls back to dev.liveReload.

rsbuild.config.ts
export default {
  dev: {
    hmr: false,
  },
};

To disable both HMR and live reload, set both dev.hmr and dev.liveReload to false. Then, no WebSocket requests will be made from the page to the dev server, and the page won't automatically refresh when files change.

rsbuild.config.ts
export default {
  dev: {
    hmr: false,
    liveReload: false,
  },
};

#Specify HMR URL

By default, Rsbuild uses the host and port number of the current page to construct the WebSocket URL for HMR.

When the HMR connection fails, you can specify the WebSocket URL by customizing the dev.client config.

rsbuild.config.ts
export default {
  dev: {
    client: {
      host: 'localhost',
      protocol: 'ws',
    },
  },
};

#File watching

By default, Rsbuild doesn't watch files in the .git/ and node_modules/ directories. When files in these directories change, Rsbuild won't trigger a rebuild. This reduces memory usage and improves build performance.

If you want to watch these directories, you can manually configure Rspack's watchOptions.ignored to override the default behavior.

For example, to watch the node_modules/ directory and ignore the .git/ directory, you can configure it as follows:

rsbuild.config.ts
export default {
  tools: {
    rspack: {
      watchOptions: {
        ignored: /\.git/,
      },
    },
  },
};

#FAQ

Refer to HMR FAQ.