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

# Solid

## 如何使用

Rspack 提供两种方案来支持 Solid：

- **使用 Rsbuild**：Rsbuild 提供对 Solid 开箱即用的支持，能够快速创建一个 Solid 项目，详见 [Rsbuild - Solid](https://rsbuild.rs/zh/guide/framework/solid)。
- **手动配置 Rspack**：你可以参考当前文档，手动添加 Solid 相关的配置。

## 配置 Solid

得益于 Rspack 对 babel-loader 的良好兼容，在 Rspack 里使用 Solid 是非常简单的。只需要 babel-loader 配合 Solid 的 [babel-solid-preset](https://www.npmjs.com/package/babel-preset-solid) 即可。Rspack 提供了一个 Solid 的[示例](https://github.com/rstackjs/rstack-examples/tree/main/rspack/solid)可供参考。

```js title="rspack.config.mjs"
import { defineConfig } from '@rspack/cli';

export default defineConfig({
  entry: {
    main: './src/index.jsx',
  },
  module: {
    rules: [
      {
        test: /\.jsx$/,
        use: [
          {
            loader: 'babel-loader',
            options: {
              presets: ['solid'],
              plugins: ['solid-refresh/babel'],
            },
          },
        ],
      },
    ],
  },
});
```
