> For AI agents: the complete documentation index is available at https://rsbuild.rs/llms.txt, the full documentation bundle is available at https://rsbuild.rs/llms-full.txt.

# server.serveAssets

- **Type:** `boolean`
- **Default:** `true` when [output.target](https://rsbuild.rs/config/output/target.md) is `web` or `web-worker`, `false` when it is `node`

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:

```ts title="rsbuild.config.ts"
export default {
  server: {
    serveAssets: false,
  },
};
```

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](https://rsbuild.rs/api/javascript-api/environment-api.md#loadbundle) and [getTransformedHtml](https://rsbuild.rs/api/javascript-api/environment-api.md#gettransformedhtml) APIs.

You can also use [server.setup](https://rsbuild.rs/config/server/setup.md) 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](https://rsbuild.rs/config/output/target.md).

For example, disable HTTP serving of a Worker's output while continuing to serve browser assets:

```ts title="rsbuild.config.ts"
export default {
  environments: {
    web: {
      output: {
        distPath: 'dist/client',
      },
    },
    worker: {
      server: {
        serveAssets: false,
      },
      output: {
        target: 'web-worker',
        distPath: 'dist/worker',
      },
    },
  },
};
```

## Public directories

Files in public directories are managed by [server.publicDir](https://rsbuild.rs/config/server/public-dir.md):

- **Development:** the dev server serves public directories independently of `serveAssets`. To stop serving public files as well, set `server.publicDir: false`.
- **Build and preview:** `publicDir.copyOnBuild` still controls whether files are copied to the output directory. The preview server treats these copies as build output, so `serveAssets` controls 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.

## Version history

| Version | Changes                     |
| ------- | --------------------------- |
| v2.3.2  | Added `server.serveAssets`. |
