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

# webpack

> **Applies to:** applications with their own `webpack.config.js` (webpack 4 or 5). Create React App, Vue CLI and the Angular webpack builder are covered on their framework pages.

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

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

| `devtool` value                   | Works with SeaLights?                                                                      |
| --------------------------------- | ------------------------------------------------------------------------------------------ |
| `source-map`, `hidden-source-map` | Yes. Full maps with columns, in `.map` files next to the bundles.                          |
| `inline-source-map`               | Yes, but the map stays inside the deployed bundle unless you rebuild.                      |
| `nosources-source-map`            | Not recommended: the maps carry no source content.                                         |
| `cheap-*`                         | No: line-only maps. The dashboard shows `Detected source-maps without column information`. |
| `eval`, `eval-*`                  | No: no source map files; code is wrapped in `eval`.                                        |
| `false` / not set in production   | No 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 webpack --mode production

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
```

* Use the folder in `output.path` as `--scanDir`.
* Add `--es6Modules` only if you build ES module output (`experiments.outputModule: true` with `output.module: true`). Default webpack output is classic scripts.

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

| Topic                                         | What to do                                                                                                                                                                                           |
| --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Vendor chunk (`splitChunks` → `vendors~*.js`) | Exclude it from the scan in `.slignore` (`**/vendors*.js`), or list the packages in `.slignore.instrument`.                                                                                          |
| `webpack:///` paths in the coverage tree      | Framework-generated sources appear as `webpack:/...`. Remove them from the scan result with `.slignore.generated` containing `webpack:/**`.                                                          |
| Module Federation                             | Each remote is its own build; see [Micro-frontends](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/browser-agent/framework-setups/micro-frontends.md). |
| `output.publicPath` set to a CDN              | With `--splitPreambleIntoFile`, pass the CDN folder as a full URL in `--preambleFileUrl`.                                                                                                            |


---

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