Registry / data / rollup-plugin-svgo

rollup-plugin-svgo

JSON →
library2.0.0jsnpmunverified

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-svgo
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-SVGO
R
rollup-plugin-svgo
datajavascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import svgo from 'rollup-plugin-svgo'
import { svgo } from 'rollup-plugin-svgo'
Plugin is a default export; named import will not work.
svgo (require)
const svgo = require('rollup-plugin-svgo')
const { svgo } = require('rollup-plugin-svgo')
CommonJS require works but must not destructure; the default export is the function itself.
type import (TypeScript)
import svgo from 'rollup-plugin-svgo'
TypeScript users can import using default import; plugin does not provide separate type exports.

Shows basic Rollup configuration using rollup-plugin-svgo with custom SVGO plugin options.

import svgo from 'rollup-plugin-svgo'; export default { input: 'src/main.js', output: { dir: 'dist', format: 'esm' }, plugins: [ svgo({ plugins: [ { removeViewBox: false }, { removeDimensions: true } ] }) ] };
Debug
Known issues
breakingVersion 2.0.0 changed plugin signature from `svgo({ raw: true })` to `svgo({ raw: true })`? No changes reported, but ensure compatibility with Rollup 3+.
fix
Update to latest rollup-plugin-svgo and Rollup 3 or 4.
affects: >=2.0.0
gotchaIf you pass no options, defaults apply: removeViewBox: false and removeDimensions: true. This may strip width/height attributes unexpectedly.
fix
Set removeDimensions: false if you want to preserve SVG dimensions.
affects: >=1.0.0
gotchaSVGO options are passed directly and must follow SVGO's plugin array format. A common mistake is passing an object instead of an array.
fix
Wrap plugin configs in an array as required by SVGO.
affects: >=0.0.0
deprecatedThe `raw: true` option disables all SVGO processing; not deprecated but may produce unexpected results if SVGO config is expected.
fix
Use `raw: true` intentionally; ensure resulting SVG is not optimized.
affects: >=1.0.0
Errors
Common errors & fixes
'svgo' is not exported from 'rollup-plugin-svgo'
Importing as named export instead of default import.
fix
Use `import svgo from 'rollup-plugin-svgo'` instead of `import { svgo } from 'rollup-plugin-svgo'`.
TypeError: svgo is not a function
Plugin is used incorrectly, possibly destructured from require.
fix
Use `const svgo = require('rollup-plugin-svgo')` (no destructuring).
Error: Unexpected plugin options shape. Expected an array.
Passed SVGO plugins as an object instead of array.
fix
Wrap plugins in array: `plugins: [{ removeViewBox: false }]`
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
svgorequiredSVGO is a peer dependency for SVG optimization logic.
rolluprequiredRollup plugin interface; required at runtime.
Agent activity
16 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
rollup-plugin-svgo — npm install rollup-plugin-svgo · libregistry