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

# Interface: Minify

The Minify configures whether to enable code minification in the production build, or to configure minimizer options.

## Properties

### backgroundOptions?

> `optional` **backgroundOptions?**: `SwcJsMinimizerRspackPluginOptions`

Overrides the Rsbuild `output.minify.jsOptions` for background-thread bundles.

#### Remarks

This option is deep-merged into `output.minify.jsOptions`.
It is mainly used together with ReactLynx dual-thread outputs so that
main-thread and background-thread bundles can use different compress rules.

#### Default Value

```ts
undefined
```

***

### css?

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

Whether enable the CSS minification.

#### Default Value

When `output.minify` is enabled and `css` is unset, this defaults to `true`.

#### Remarks

When building for production, [@rsbuild/plugin-css-minimizer](https://github.com/rspack-contrib/rsbuild-plugin-css-minimizer) is used to minify CSS assets for better transmission efficiency.

#### Example

- Disable the CSS minification.

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

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

***

### js?

> `optional` **js?**: `boolean`

Whether enable the JavaScript minification.

#### Default Value

When `output.minify` is enabled and `js` is unset, this defaults to `true`.

#### Example

- Disable the JavaScript minification.

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

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

***

### jsOptions?

> `optional` **jsOptions?**: `SwcJsMinimizerRspackPluginOptions`

[Minify.jsOptions](#jsoptions) is used to configure SWC minification options.

#### Default Value

When JavaScript minification is enabled and `jsOptions` is unset, this defaults to `{}`.

#### Remarks

For detailed configurations, please refer to [SwcJsMinimizerRspackPlugin](https://rspack.rs/plugins/rspack/swc-js-minimizer-rspack-plugin).

#### Example

- Disable the mangle feature.

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

export default defineConfig({
  output: {
    minify: {
      jsOptions: {
        minimizerOptions: {
          mangle: false,
        },
      },
    },
  },
})
```

***

### mainThreadOptions?

> `optional` **mainThreadOptions?**: `SwcJsMinimizerRspackPluginOptions`

Overrides the Rsbuild `output.minify.jsOptions` for main-thread bundles.

#### Remarks

This option is deep-merged into `output.minify.jsOptions`.
It is mainly used together with ReactLynx dual-thread outputs so that
main-thread and background-thread bundles can use different compress rules.

#### Default Value

```ts
undefined
```

#### Example

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

export default defineConfig({
  output: {
    minify: {
      jsOptions: {
        minimizerOptions: {
          compress: {
            pure_funcs: ['console.log'],
          },
        },
      },
      mainThreadOptions: {
        minimizerOptions: {
          compress: {
            pure_funcs: ['NativeModules.call', 'lynx.getJSModule'],
          },
        },
      },
    },
  },
})
```
