{"id":22250,"library":"rollup-plugin-svgo","title":"rollup-plugin-svgo","description":"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.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/porsager/rollup-plugin-svgo","tags":["javascript","rollup-plugin","svg","svgo"],"install":[{"cmd":"npm install rollup-plugin-svgo","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-svgo","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-svgo","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"SVGO is a peer dependency for SVG optimization logic.","package":"svgo","optional":false},{"reason":"Rollup plugin interface; required at runtime.","package":"rollup","optional":false}],"imports":[{"note":"Plugin is a default export; named import will not work.","wrong":"import { svgo } from 'rollup-plugin-svgo'","symbol":"default","correct":"import svgo from 'rollup-plugin-svgo'"},{"note":"CommonJS require works but must not destructure; the default export is the function itself.","wrong":"const { svgo } = require('rollup-plugin-svgo')","symbol":"svgo (require)","correct":"const svgo = require('rollup-plugin-svgo')"},{"note":"TypeScript users can import using default import; plugin does not provide separate type exports.","wrong":null,"symbol":"type import (TypeScript)","correct":"import svgo from 'rollup-plugin-svgo'"}],"quickstart":{"code":"import svgo from 'rollup-plugin-svgo';\n\nexport default {\n  input: 'src/main.js',\n  output: {\n    dir: 'dist',\n    format: 'esm'\n  },\n  plugins: [\n    svgo({\n      plugins: [\n        { removeViewBox: false },\n        { removeDimensions: true }\n      ]\n    })\n  ]\n};","lang":"javascript","description":"Shows basic Rollup configuration using rollup-plugin-svgo with custom SVGO plugin options."},"warnings":[{"fix":"Update to latest rollup-plugin-svgo and Rollup 3 or 4.","message":"Version 2.0.0 changed plugin signature from `svgo({ raw: true })` to `svgo({ raw: true })`? No changes reported, but ensure compatibility with Rollup 3+.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Set removeDimensions: false if you want to preserve SVG dimensions.","message":"If you pass no options, defaults apply: removeViewBox: false and removeDimensions: true. This may strip width/height attributes unexpectedly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Wrap plugin configs in an array as required by SVGO.","message":"SVGO options are passed directly and must follow SVGO's plugin array format. A common mistake is passing an object instead of an array.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use `raw: true` intentionally; ensure resulting SVG is not optimized.","message":"The `raw: true` option disables all SVGO processing; not deprecated but may produce unexpected results if SVGO config is expected.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `import svgo from 'rollup-plugin-svgo'` instead of `import { svgo } from 'rollup-plugin-svgo'`.","cause":"Importing as named export instead of default import.","error":"'svgo' is not exported from 'rollup-plugin-svgo'"},{"fix":"Use `const svgo = require('rollup-plugin-svgo')` (no destructuring).","cause":"Plugin is used incorrectly, possibly destructured from require.","error":"TypeError: svgo is not a function"},{"fix":"Wrap plugins in array: `plugins: [{ removeViewBox: false }]`","cause":"Passed SVGO plugins as an object instead of array.","error":"Error: Unexpected plugin options shape. Expected an array."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}