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

# tools.styleLoader

- **类型：** `Object | Function`
- **默认值：** `{}`

通过 `tools.styleLoader` 可以设置 [style-loader](https://github.com/webpack/style-loader) 的配置项。

值得注意的是，Rsbuild 默认不会开启 `style-loader`，你可以通过 [output.injectStyles](/zh/config/output/inject-styles.md) 配置项来开启它。

## Object 类型

当 `tools.styleLoader` 是一个 object 时，它会与默认配置通过 `Object.assign` 合并。

```ts title="rsbuild.config.ts"
export default {
  tools: {
    styleLoader: {
      insert: 'head',
    },
  },
};
```

## Function 类型

当 `tools.styleLoader` 是一个 function 时，默认选项会作为第一个参数传入，你可以直接修改这个对象，也可以返回一个新的对象作为最终使用的选项。比如：

```ts title="rsbuild.config.ts"
export default {
  tools: {
    styleLoader: (config) => {
      config.insert = 'head';
      return config;
    },
  },
};
```
