1 unstable release

0.1.0 Apr 11, 2026

#1192 in Cargo plugins


Used in 2 crates (via svgpack_core)

MIT license

14KB
134 lines

svgpack

Fast SVG optimizer for build pipelines, implemented in Rust.

This repository contains the first working version of svgpack as a Rust workspace with:

  • CLI command entrypoint
  • Core optimization pipeline orchestration
  • Basic parser helpers
  • MVP optimizer passes
  • Sprite generation (symbol format)
  • React component code generation
  • Duplicate detection
  • Basic SVG analysis reporting

Current status

Version target: v0.1.0 (MVP foundation).

Implemented:

  • optimize flow (single file or directory)
  • --in-place, --dry-run, --stats, and --format json
  • sprite subcommand
  • codegen subcommand (--framework react)
  • dedup subcommand
  • analyze subcommand

Workspace layout

svgpack/
├── Cargo.toml
├── crates/
│   ├── svgpack_cli/
│   ├── svgpack_core/
│   ├── svgpack_parser/
│   ├── svgpack_optimizer/
│   ├── svgpack_sprite/
│   ├── svgpack_codegen/
│   ├── svgpack_dedup/
│   ├── svgpack_analysis/
│   └── svgpack_config/
└── tests/
    └── fixtures/

Build

Requirements:

  • Rust stable toolchain
  • Cargo

Commands:

cargo fmt
cargo check
cargo test

CLI usage

Run via cargo:

cargo run -p svgpack_cli -- <args>

Optimize:

cargo run -p svgpack_cli -- icons/ -o dist/icons/ --stats

Optimize in place:

cargo run -p svgpack_cli -- icons/ --in-place

Dry run:

cargo run -p svgpack_cli -- icons/ --dry-run --stats

JSON output:

cargo run -p svgpack_cli -- icons/ --format json

Sprite generation:

cargo run -p svgpack_cli -- sprite icons/ -o dist/sprite.svg

React codegen:

cargo run -p svgpack_cli -- codegen icons/ -o src/icons/ --framework react --index

Duplicate detection:

cargo run -p svgpack_cli -- dedup icons/

Analyze:

cargo run -p svgpack_cli -- analyze icons/

Config

You can pass a JSON config with --config:

cargo run -p svgpack_cli -- --config svgpack.config.json icons/ -o dist/icons/

Supported now:

  • preset
  • multipass
  • max_passes
  • passes map (enabled, precision, prefix)

Roadmap

  • v0.2: stronger path/transforms optimization + better SVGO parity.
  • v0.3: sprite improvements + React/Vue codegen hardening.
  • v0.4: build-tool plugins (Vite/Rspack/Webpack) + watch mode.
  • v1.0: stable API, regression corpus, performance benchmarks.

Notes

  • This is a first version focused on architecture and working command flow.
  • Path-data optimization is still minimal and should be expanded in the next iteration.
  • Visual regression tests and SVGO compatibility mapping are planned next.

Dependencies

~3.5–4.5MB
~75K SLoC