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

# Vue

> **Applies to:** Vue 2 and Vue 3 applications built with Vite or Vue CLI. For Nuxt, follow the server-side rendering note below.

| Toolchain           | Source maps                               | Output to scan | `--es6Modules` |
| ------------------- | ----------------------------------------- | -------------- | -------------- |
| Vite (`create-vue`) | Off by default; turn on `build.sourcemap` | `dist`         | Yes            |
| Vue CLI (webpack)   | On by default (`productionSourceMap`)     | `dist`         | No             |

Vue single-file components (`.vue`) are reported on the `.vue` file itself, with each method on its line in the `<script>` or `<script setup>` block. Code compiled from `<template>` is marked as generated, not reported as your methods. **The `.vue` source files must be present in the workspace where `slnodejs scan` runs** (a normal CI checkout).

## Vue with Vite <a href="#vite" id="vite"></a>

```js
// vite.config.js
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
  plugins: [vue()],
  build: { sourcemap: true },
});
```

```bash
printf '%s' "$SEALIGHTS_AGENT_TOKEN" > sltoken.txt
npm ci
npx vite build

npx slnodejs config --tokenFile sltoken.txt --appName my-vue-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
```

## Vue with Vue CLI <a href="#vue-cli" id="vue-cli"></a>

Source maps are on by default. Make sure `vue.config.js` does not set `productionSourceMap: false`:

```js
// vue.config.js
module.exports = {
  productionSourceMap: true,
};
```

```bash
printf '%s' "$SEALIGHTS_AGENT_TOKEN" > sltoken.txt
npm ci
npx vue-cli-service build

npx slnodejs config --tokenFile sltoken.txt --appName my-vue-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`.

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

| Topic                                               | What to do                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Vue itself                                          | `vue`, `@vue/`, `vue-router`, `vuex` and `pinia` inside your bundles are not instrumented by default.                                                                                                                                                                                                                                                                                                                                                               |
| Upgrading from an older `slnodejs`                  | Newer versions report `.vue` methods on their real file and line. The first build after the upgrade shows a one-time jump in "new methods" in coverage and Test Impact Analysis history.                                                                                                                                                                                                                                                                            |
| Server-side rendering (Nuxt, Vue SSR)               | Scan the client bundles with `--instrumentForBrowsers` and the server bundles 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). The server needs the `.vue` source files where the test listener runs to place coverage on the right lines. |
| `--splitPreambleIntoFile` with history-mode routing | Pass a full URL in `--preambleFileUrl`, or set `<base href>`.                                                                                                                                                                                                                                                                                                                                                                                                       |

## Check it <a href="#check" id="check"></a>

* Before CI: `npx slnodejs dryRun --scanDir dist --es6Modules --verbose --instrumentForBrowsers --tokenFile sltoken.txt` (Vue CLI: without `--es6Modules`). `sl-mapping.json` should resolve to `src/**/*.vue` and `src/**/*.ts` files.
* After deployment: [Check that it works](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/browser-agent/setting-up-browser-coverage.md#check-that-it-works).


---

# 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/vue.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.
