> 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: DefineDceVisitorConfig

类似各类打包工具中的 `define`，但它在转换阶段执行，并会执行一次死代码消除（DCE）。

## Properties

### define

> **define**: `Record`\<`string`, `string`>

在编译时将代码中的变量替换为其他值或表达式。

#### Remarks

注意：与 `source.define` 的区别

`defineDCE` 在转换 `background-only` 指令之前执行。因此可用于从主线程代码中消除仅在后台线程使用的代码。

#### Example

```js
import { defineConfig } from '@lynx-js/rspeedy'
import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'

export default defineConfig({
  plugins: [
    pluginReactLynx({
      defineDCE: {
        define: {
          __FOO__: 'false',
          'process.env.PLATFORM': '"lynx"',
        },
      },
    })
  ],
})
```

Then, `__FOO__` and `process.env.PLATFORM` could be used in source code.

```
if (process.env.PLATFORM === 'lynx') {
  console.log('lynx')
}

function FooOrBar() {
  if (__FOO__) {
    return <text>foo</text>
  } else {
    return <text>bar</text>
  }
}
```
