Rollup plugin that inlines SVG files as strings or data URIs. Current stable version is 3.0.3 (released 2022). Requires Rollup as a peer dependency. Supports both ES modules and CommonJS output. Key differentiator: lightweight, TypeScript types included, and allows custom transformations via options. Alternatives like @svgr/rollup focus on React components, while this plugin is framework-agnostic and simpler for raw SVG inlining.
npm install rollup-plugin-inline-svgVerified import paths — ran on the pinned version, not inferred.
Shows how to import and configure the plugin in a Rollup config, including custom transform and SVG import example.
Use import icon from './icon.svg?inline' instead of plain './icon.svg'.
Add option { dataUri: true } to inlineSvg().If you need Rollup to output CommonJS, use @rollup/plugin-commonjs or set output.format to 'cjs' and ensure the plugin works with it.
Use Rollup's own include/exclude patterns via the plugin's options or Rollup's 'watch' options.
Run 'npm install rollup-plugin-inline-svg' or ensure it's in package.json.
Use 'import inlineSvg from "rollup-plugin-inline-svg"' (default import).
Upgrade to v3.0.0+ or remove the dataUri option.