svg-minifier (v2.0.0) is a Node.js tool to minify SVG files by optimizing them with SVGO and optionally generating a metadata JSON and runtime script. It supports batch processing from multiple directories, callbacks for SVG content, DOM manipulation via Cheerio, and custom naming with type suffixes. Compared to standalone SVGO, it provides a higher-level batch workflow with built-in metadata output, duplicate logging, and error handling. Release cadence is irregular, maintained by cenfun.
npm install svg-minifierNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic usage: minify all SVG files in the 'icons' directory, output metadata and runtime to 'dist'.
Check your usage of lz-utils; if relying on it directly, pin to version 1.x or update accordingly.
Refer to the options.js file for expected signatures; no types available.
Always set outputDir to a valid path if you expect output files. For in-memory only, set outputMetadata: false.
If you want to exclude a file, return false from onSVGOptimized. Do not remove the element from Cheerio.
Install @types/svg-minifier (if available) or declare module 'svg-minifier' manually.
npm install lz-utils
Use const svgMinifier = require('svg-minifier');Ensure dirs is an array of directory paths or objects.
No dependency data recorded yet.