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, and this page is available as Markdown at https://yichenzhu1337.github.io/rspack-plugin-svg-sprite/docs/options.md.

Options

Loader options

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

OptionTypeDefaultDescription
symbolIdstring | function'[name]'Pattern for generating symbol IDs. Supports [name], [folder], [ext] placeholders, or a function (filePath) => id.
esModulebooleantrueUse ES module export (export default) vs CommonJS (module.exports).
extractbooleanfalseEnable extract mode to emit an external sprite file instead of inlining.
spriteFilenamestring'sprite.svg'Output filename for the extracted sprite (extract mode only). Symbol ids must be unique within one sprite file.
publicPathstring''Public URL prefix for the sprite file (extract mode only). Read from output.publicPath if not set; 'auto' and function values resolve at runtime.
contentbooleantrueExtract 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.

OptionTypeDefaultDescription
plainSpritebooleanfalseGenerate a plain sprite without preview styles and <use> elements.
spriteAttrsobject{}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 for the table. This matches svg-sprite-loader's export shape, so migrating needs no component changes.