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

# Interface: SourceMap

SourceMap 用于配置是否为产物生成 source map，以及如何生成。

## Properties

### css?

> `optional` **css?**: `boolean`

是否生成 CSS source map。

#### Default Value

在 Lynx environment 中为 `true`，其他情况下为 `false`。

#### Remarks

Lynx environment 中会启用 CSS source map，以便将 CSS 诊断信息映射回源码；所有 `.map` 资源都会在输出前被移除。

#### Example

禁用 CSS source map。

```js
import { defineConfig } from '@lynx-js/rspeedy'

export default defineConfig({
  output: {
    sourceMap: {
      css: false,
    },
  },
})
```

***

### js?

> `optional` **js?**: `DevTool`

source map 的生成方式。设置为 `false` 将禁用 source map。

#### Default Value

当 `output.sourceMap` 为对象且未设置 `js` 时，开发环境下默认为 `'cheap-module-source-map'`。生产环境下，Lynx environment 默认为 `'source-map'`，其他情况下默认为 `false`。

#### Remarks

详见 [Rspack - Devtool](https://rspack.rs/config/devtool)。

#### Examples

- 在生产环境中启用高质量的 source map：

```js
import { defineConfig } from '@lynx-js/rspeedy'

export default defineConfig({
  output: {
    sourceMap: {
      js: process.env['NODE_ENV'] === 'production'
        ? 'source-map'
        : 'cheap-module-source-map',
    },
  },
})
```

- 禁用 source map 生成：

```js
import { defineConfig } from '@lynx-js/rspeedy'

export default defineConfig({
  output: {
    sourceMap: {
      js: false,
    },
  },
})
```

- 在所有环境中使用高质量的 source map：

```js
import { defineConfig } from '@lynx-js/rspeedy'

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