server.serveAssets
- Type:
boolean - Default:
truewhen output.target isweborweb-worker,falsewhen it isnode
Controls whether Rsbuild's dev and preview servers serve build output over HTTP, including JavaScript, CSS, HTML, and source maps.
Set this option to false to stop serving build output over HTTP:
Setting this option to false does not affect compilation, file watching, or writing output to disk. You can still access the output through the dev server's loadBundle and getTransformedHtml APIs.
You can also use server.setup to add custom routes that handle HTTP requests for build output.
Multiple environments
Each environment inherits the top-level server.serveAssets value and can override it with its own setting. If neither is set, the default depends on that environment's output.target.
For example, disable HTTP serving of a Worker's output while continuing to serve browser assets:
Public directories
Files in public directories are managed by server.publicDir:
- Development: the dev server serves public directories independently of
serveAssets. To stop serving public files as well, setserver.publicDir: false. - Build and preview:
publicDir.copyOnBuildstill controls whether files are copied to the output directory. The preview server treats these copies as build output, soserveAssetscontrols whether they are served.
Overlapping output directories
When environments share an output directory, or one output directory contains another, an environment with serveAssets: true can also serve files from an environment with serveAssets: false.
For example, an environment serving dist can also serve files in dist/worker, even if the Worker environment sets serveAssets: false. Use separate directories such as dist/client and dist/worker when environments have different serveAssets settings.

