{"id":22249,"library":"rollup-plugin-svg-sprite","title":"rollup-plugin-svg-sprite","description":"Rollup plugin to extract SVG imports from your bundle and generate an external SVG sprite file, with optional optimization via SVGO. Current stable version is 1.0.0. Released on a low cadence. Key differentiators: native Rollup integration using generateBundle hook, support for SVGO optimization, minification enabled by default, and tests with 100% code coverage. Alternative to webpack-based solutions like svg-sprite-loader.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/vladshcherbin/rollup-plugin-svg-sprite","tags":["javascript","rollup","rollup-plugin","svg","sprite","svg-sprite","svgo","create","generate"],"install":[{"cmd":"npm install rollup-plugin-svg-sprite","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-svg-sprite","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-svg-sprite","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM only. CommonJS require is not supported for this ES module.","wrong":"const svgSprite = require('rollup-plugin-svg-sprite')","symbol":"default","correct":"import svgSprite from 'rollup-plugin-svg-sprite'"},{"note":"The export is a function, not a class. Do not use `new`.","wrong":"new svgSprite({ outputFolder: 'dist/public' })","symbol":"svgSprite as function call in config","correct":"svgSprite({ outputFolder: 'dist/public' })"},{"note":"The package exports a single function from the main entry. Subpath imports are not needed.","wrong":"import svgSprite from 'rollup-plugin-svg-sprite/dist/index.js'","symbol":"Rollup configuration import","correct":"import svgSprite from 'rollup-plugin-svg-sprite'"}],"quickstart":{"code":"// rollup.config.js\nimport svgSprite from 'rollup-plugin-svg-sprite'\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'iife'\n  },\n  plugins: [\n    svgSprite({\n      outputFolder: 'dist/public'\n    })\n  ]\n}\n\n// Then in your source files:\nimport './svg/icon1.svg'\nimport './svg/icon2.svg'","lang":"javascript","description":"Rollup config using rollup-plugin-svg-sprite to generate an external SVG sprite from imported SVGs."},"warnings":[{"fix":"Replace `prettify: true/false` with `minify: false` if you need unminified sprite.","message":"v1.0.0 removes the `prettify` option. The sprite is minified by default; use `minify` to control.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Upgrade Node to version 8.3 or higher.","message":"v1.0.0 drops Node 6 support. Requires Node >=8.3.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Upgrade plugin to v0.3.0+ and use the new `generateBundle` hook.","message":"v0.3.0 replaces deprecated `onwrite` hook with `generateBundle`. Using older version with Rollup >=1.0.0 fails.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Upgrade Rollup to 1.0.0 or later, and plugin to v0.3.0+.","message":"v0.3.0 sets rollup peer dependency to >=1.0.0. Incompatible with Rollup <1.0.0.","severity":"breaking","affected_versions":"<0.3.0"},{"fix":"Add a <script> or <link> to the generated sprite file in your HTML, or use a loader that injects it automatically.","message":"The plugin only generates the sprite file; it does not inject a reference into your bundle. You must manually include the sprite in your HTML.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `import svgSprite from 'rollup-plugin-svg-sprite'` in an ES module context.","cause":"Using require() instead of import, or importing from wrong path.","error":"TypeError: svgSprite is not a function"},{"fix":"Run `npm install rollup-plugin-svg-sprite --save-dev` or `yarn add rollup-plugin-svg-sprite --dev`.","cause":"The package is not installed in your project's node_modules.","error":"Error: Plugin error: Cannot find module 'rollup-plugin-svg-sprite'"},{"fix":"Provide an `outputFolder` string, e.g., `svgSprite({ outputFolder: 'dist/public' })`.","cause":"Missing required `outputFolder` option in the plugin configuration.","error":"Error: outputFolder is required"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}