A Rollup plugin that imports SVG files and optimizes them using SVGO (SVG Optimizer). Current stable version is 2.0.0. The plugin processes SVG files through SVGO to remove redundant and useless information (editor metadata, comments, hidden elements, non-optimal values) and exports the cleaned SVG content as a string. Key differentiators: simple integration with Rollup, passes through raw SVG content with `raw: true`, and allows direct configuration of SVGO plugins via plugin options. Unlike generic asset imports, it specifically pairs with SVGO for optimized inline SVG usage in JavaScript bundles.
npm install rollup-plugin-svgoVerified import paths — ran on the pinned version, not inferred.
Shows basic Rollup configuration using rollup-plugin-svgo with custom SVGO plugin options.
Update to latest rollup-plugin-svgo and Rollup 3 or 4.
Set removeDimensions: false if you want to preserve SVG dimensions.
Wrap plugin configs in an array as required by SVGO.
Use `raw: true` intentionally; ensure resulting SVG is not optimized.
Use `import svgo from 'rollup-plugin-svgo'` instead of `import { svgo } from 'rollup-plugin-svgo'`.Use `const svgo = require('rollup-plugin-svgo')` (no destructuring).Wrap plugins in array: `plugins: [{ removeViewBox: false }]`