> For AI agents: the complete documentation index is available at https://yichenzhu1337.github.io/rspack-plugin-svg-sprite/docs/llms.txt, the full documentation bundle is available at https://yichenzhu1337.github.io/rspack-plugin-svg-sprite/docs/llms-full.txt.

# Options

## Loader options

Set on the rule that uses `rspack-plugin-svg-sprite/loader`.

| Option           | Type                 | Default        | Description                                                                                                                                                                                   |
| ---------------- | -------------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `symbolId`       | `string \| function` | `'[name]'`     | Pattern for generating symbol IDs. Supports `[name]`, `[folder]`, `[ext]` placeholders, or a function `(filePath) => id`.                                                                     |
| `esModule`       | `boolean`            | `true`         | Use ES module export (`export default`) vs CommonJS (`module.exports`).                                                                                                                       |
| `extract`        | `boolean`            | `false`        | Enable extract mode to emit an external sprite file instead of inlining.                                                                                                                      |
| `spriteFilename` | `string`             | `'sprite.svg'` | Output filename for the extracted sprite (extract mode only). Symbol ids must be unique within one sprite file.                                                                               |
| `publicPath`     | `string`             | `''`           | Public URL prefix for the sprite file (extract mode only). Read from `output.publicPath` if not set; `'auto'` and function values resolve at runtime.                                         |
| `content`        | `boolean`            | `true`         | Extract mode only: set `false` to leave the `<symbol>` markup out of each module (`icon.content` is then `''`). The sprite file is unchanged. Ignored in inline mode, which needs the markup. |

`include` and `exclude` are not loader options. To limit which SVGs become sprite symbols, use the `include` / `exclude` conditions of the bundler rule itself, or the options of the same name on the Rsbuild plugin (`pluginSvgSprite({ include: /icons/ })`).

## Plugin options

Passed to `new SvgSpritePlugin({ ... })`. The plugin is only needed in extract mode.

| Option        | Type      | Default | Description                                                             |
| ------------- | --------- | ------- | ----------------------------------------------------------------------- |
| `plainSprite` | `boolean` | `false` | Generate a plain sprite without preview styles and `<use>` elements.    |
| `spriteAttrs` | `object`  | `{}`    | Additional attributes to add to the root `<svg>` element of the sprite. |

## Rsbuild plugin options

`pluginSvgSprite(options)` from `rspack-plugin-svg-sprite/rsbuild` accepts `symbolId`, `extract`, `esModule`, `spriteFilename`, `publicPath`, `content`, `plainSprite`, `spriteAttrs`, `include` and `exclude` (a `RegExp` or a string). The defaults are the ones above.

## Exported symbol shape

Every `import icon from './icon.svg'` returns `{ id, viewBox, url, content }`. See [Getting started](https://yichenzhu1337.github.io/rspack-plugin-svg-sprite/docs/getting-started.md#use-in-your-components) for the table. This matches `svg-sprite-loader`'s export shape, so migrating needs no component changes.
