undefinedWatch specified files and directories for changes. When a change is detected, it can trigger a page reload or restart the dev server.
string | string[]undefinedPaths of the files or directories to watch, supports glob syntax. It can be a single path or an array of multiple paths.
'reload-page' | 'reload-server''reload-page'Specifies whether to trigger a page reload or restart the dev server when a file changes.
reload-page means that when a file changes, the page in the browser will automatically reload. If the type is not explicitly specified, Rsbuild defaults to the reload-page behavior.
This can be used to watch changes to static assets, such as files in the public directory.
If both dev.hmr and dev.liveReload are set to
false, the page will not automatically reload.
reload-server means that the dev server will automatically restart when a file changes. This can be used to watch changes to configuration files, such as modules imported by your rsbuild.config.ts file.
For example, if you maintain some common configuration files in the config directory, such as common.ts, you may want the dev server to automatically restart when these files change. Example configuration:
Note that the reload-server functionality is provided by Rsbuild CLI. If you are using a custom server or a framework built on top of Rsbuild, this configuration is currently not supported.
ChokidarOptionsundefinedwatchFiles is implemented based on chokidar v4, and you can pass chokidar options through options.
watchFiles is not applicable for watching build dependency files. When an Rsbuild build starts, the underlying Rspack automatically watches all build dependencies. Any changes to these files will trigger a new build.
If you want to prevent some files from triggering a rebuild when they change, you can use Rspack's watchOptions.ignored configuration item.
See HMR - File Watching for details.