> 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/vite.md).

# Vite (Svelte, Solid, Preact, Lit)

> **Applies to:** any application built with `vite build`: Svelte, SolidJS, Preact, Lit, vanilla JavaScript or TypeScript. React and Vue have their own pages: [React](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/browser-agent/framework-setups/react.md), [Vue](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/browser-agent/framework-setups/vue.md).

Vite builds ES module bundles into `dist/assets`, so scan with `--es6Modules`.

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

```js
// vite.config.js
import { defineConfig } from 'vite';

export default defineConfig({
  build: {
    sourcemap: true,   // or 'hidden': no sourceMappingURL comment, .map files still next to the bundles
  },
});
```

Do not use `sourcemap: 'inline'` if you deploy the build output without the scan step in between: inline maps stay inside the bundles.

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

```bash
printf '%s' "$SEALIGHTS_AGENT_TOKEN" > sltoken.txt
npm ci
npx vite 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 --es6Modules \
  --instrumentForBrowsers --outputPath sl_dist \
  --labId qa-env --excludeSourceMapFiles skipCopy
```

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

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

| Topic                                              | What to do                                                                                                                                                                                                                                                                                                                                                                                                            |
| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Svelte                                             | `svelte` and `@sveltejs/` inside your bundles are not instrumented by default.                                                                                                                                                                                                                                                                                                                                        |
| SvelteKit, SolidStart, Astro with server rendering | Scan the client output with `--instrumentForBrowsers` and the server output without it, each with its own `--moduleName`, like the [Next.js setup](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/node.js-agent/advanced-features/next.js-with-sealights-node-and-browser-agents-multi-module-scan.md). With a static adapter (no server), scan the static output only. |
| `base` option (app served under a sub-path)        | With `--splitPreambleIntoFile`, pass a full URL in `--preambleFileUrl` that includes the sub-path.                                                                                                                                                                                                                                                                                                                    |
| Legacy plugin (`@vitejs/plugin-legacy`)            | It emits `*-legacy-*.js` copies for old browsers. Exclude them in `.slignore` (`**/*-legacy-*.js`), or they are reported as duplicate methods.                                                                                                                                                                                                                                                                        |
| Vitest unit tests                                  | Captured separately; see [Other Test Frameworks](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/node.js-agent/capturing-tests/other-test-frameworks.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/vite.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.
