> For the complete documentation index, see [llms.txt](https://docs.sealights.io/knowledgebase/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/browser-agent/framework-setups/rsbuild-and-rspack.md).

# Rsbuild and Rspack

> **Applies to:** applications built with [Rsbuild](https://rsbuild.dev) or directly with Rspack, including Rsbuild-based React, Vue and Svelte templates.

Rsbuild builds with Rspack (a webpack-compatible bundler) and writes classic-script bundles to `dist/static/js` by default, so do not add `--es6Modules` unless you changed the output to ES modules.

## Step 1: Source maps <a href="#source-maps" id="source-maps"></a>

Rsbuild turns JavaScript source maps off in production builds by default. Turn them on:

{% tabs %}
{% tab title="Rsbuild" %}

```ts
// rsbuild.config.ts
import { defineConfig } from '@rsbuild/core';

export default defineConfig({
  output: {
    sourceMap: {
      js: 'source-map',   // or 'hidden-source-map'
    },
  },
});
```

{% endtab %}

{% tab title="Rspack" %}

```js
// rspack.config.js
module.exports = {
  mode: 'production',
  devtool: 'source-map',   // or 'hidden-source-map'
  // ...
};
```

{% endtab %}
{% endtabs %}

Do not use `cheap-*` or `eval-*` values; see the `devtool` table on [webpack](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/browser-agent/framework-setups/webpack.md#source-maps).

## Step 2: Build, scan and instrument <a href="#scan" id="scan"></a>

```bash
printf '%s' "$SEALIGHTS_AGENT_TOKEN" > sltoken.txt
npm ci
npx rsbuild build        # or: npx rspack build

npx slnodejs config --tokenFile sltoken.txt --appName my-web-app \
  --branchName "$BRANCH_NAME" --buildName "$BUILD_NUMBER"
npx slnodejs scan --tokenFile sltoken.txt --buildSessionIdFile buildSessionId \
  --scanDir dist --scmType git \
  --instrumentForBrowsers --outputPath sl_dist \
  --labId qa-env --excludeSourceMapFiles skipCopy
```

Deploy the contents of `sl_dist` in place of `dist`.

## Rsbuild-specific notes <a href="#notes" id="notes"></a>

| Topic                                    | What to do                                                                                                                                                             |
| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `output.distPath.root` changed           | Use that folder as `--scanDir`.                                                                                                                                        |
| `lib-*.js` / `vendors-*.js` split chunks | They hold `node_modules` code. Exclude them in `.slignore` (for example `**/lib-*.js`), or rely on `.slignore.instrument` for framework packages.                      |
| `webpack://` or `rspack://` source paths | Remove framework-generated sources from the scan result with `.slignore.generated` (for example `webpack:/**`).                                                        |
| Module Federation                        | See [Micro-frontends](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/browser-agent/framework-setups/micro-frontends.md). |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/browser-agent/framework-setups/rsbuild-and-rspack.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
