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

The CssLoader controls the options of [css-loader](https://github.com/webpack-contrib/css-loader).

## Remarks

The default option is as follow:

```js
const defaultOptions = {
  modules: {
    auto: true,
    namedExport: false,
    exportLocalsConvention: 'camelCase',
    localIdentName: output.cssModules.localIdentName,
  },
  sourceMap: output.sourceMap,
  // importLoaders is `1` when compiling css files, and is `2` when compiling sass/less files
  importLoaders: 1 || 2,
};
```

## Properties

### importLoaders?

> `optional` **importLoaders?**: `0` | `1` | `2`

The option `importLoaders` allows you to configure how many loaders before `css-loader` should be applied to `@imported` resources and CSS modules imports.

#### Default Value

`1` when compiling CSS files and `2` when compiling Sass or Less files

#### Remarks

See [css-loader#import-loaders](https://github.com/webpack-contrib/css-loader?tab=readme-ov-file#importloaders) for details.

***

### modules?

> `optional` **modules?**: `boolean` | [`CssLoaderModules`](/next/api/packages/rspeedy/interfaces/CssLoaderModules.md) | `"local"` | `"global"` | `"pure"` | `"icss"`

The [cssLoader.modules](/next/api/packages/rspeedy/interfaces/CssLoaderModules.md) option enables/disables the CSS Modules specification and setup basic behavior.

#### Default Value

Enables CSS Modules with automatic `*.module.*` detection, camelCase exports, `namedExport: false`, and `localIdentName` inherited from `output.cssModules.localIdentName`.

#### Examples

Using `false` value to increase performance because we avoid parsing CSS Modules features, it will be useful for developers who use vanilla css or use other technologies.

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

export default defineConfig({
  tools: {
    cssLoader: {
      modules: false,
    },
  },
})
```

Using `() => true` value to enable CSS Modules for all files.

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

export default defineConfig({
  tools: {
    cssLoader: {
      modules: () => true,
    },
  },
})
```

Using object value to enable CSS Modules based-on [CssLoaderModules.auto](/next/api/packages/rspeedy/interfaces/CssLoaderModules.md#auto) option and setup more configurations about CSS Modules.

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

export default defineConfig({
  tools: {
    cssLoader: {
      modules: {
        namedExport: true,
      },
    },
  },
})
```
