---
sidebar_label: swc
---

# tools.swc

- **Type:** `Object`
- **Default:** `undefined`

## Introduction

import SWC from '@modern-js/builder-doc/docs/en/shared/swc.md';

<SWC />

:::tip
When using Rspack as the bundler, SWC will be used for transpiling and compression by default, so you don't need to install or configure the SWC plugin.
:::

## Install

First, you need to execute `pnpm run new` to enable the SWC compile:

```bash
? Please select the operation you want: Enable features
? Please select the feature name: Enable SWC Compile
```

After the installation, please register the SWC plugin in the `modern.config.ts` file, then the SWC compilation and compression will be enabled.

```ts title="modern.config.ts"
import appTools, { defineConfig } from '@modern-js/app-tools';
import swcPlugin from '@modern-js/plugin-swc';

export default defineConfig({
  plugins: [appTools(), swcPlugin()],
});
```

## Config

You can set the SWC compilation behavior through the `tools.swc` config.

```js title="modern.config.ts"
import { defineConfig } from '@modern-js/app-tools';

export default defineConfig({
  tools: {
    swc: {
      jsMinify: {
        compress: {},
        mangle: true,
      },
    },
  },
});
```

For config details, please refer to [Modern.js Builder - SWC Plugin Configuration](https://modernjs.dev/builder/en/plugins/plugin-swc.html#config).
