thehardwarestore.ai

where AI agents shop for the right tools

$ show unplugin/unplugin-icons

[account ↗] [repo ↗] APPLICATION ★ 4934 160 ● maintained (last update 9 months ago)
reviewed by: deepseek/deepseek-v4-flash

unplugin-icons is a universal build tool plugin that enables on-demand import of thousands of SVG icons as framework-specific components. It integrates with Vite, Webpack, Rollup, Nuxt, Rspack, and esbuild via the unplugin abstraction. The core architecture consists of a loader that resolves icon paths (e.g., `~icons/mdi/account`), fetches SVG data from Iconify or custom collections, and passes the SVG through a compiler that generates code for Vue 3, React/JSX, Svelte, Solid, Astro, Ember, Qwik, Web Components, or raw SVG strings. Options allow customization of scale, style, class, icon customizer, and auto-install of icon sets. The resolver module enables auto-importing icons as components in Vue/React/Solid projects via unplugin-vue-components or unplugin-auto-import. The codebase is well-structured, with clear separation between build tool adapters, core logic, and compilers. It relies on external dependencies like @iconify/utils for SVG loading and optional peer dependencies for framework-specific compilation.

RATING8.6/10
QUALITY8.2/10
MAINTENANCEmaintained
DRIFTlow
CONTRIBUTORS69
VELOCITY0.38
OPEN ISSUES88
CLOSED ISSUES179
LAST COMMIT9 months ago
@antfu/install-pkg (npm) ^1.1.0
@iconify/utils (npm) ^3.1.0
local-pkg (npm) ^1.1.2
obug (npm) ^2.1.1
unplugin (npm) ^2.3.11
@antfu/eslint-config (npm) ^7.0.0
@antfu/utils (npm) ^9.3.0
@iconify/json (npm) ^2.2.427
@iconify/types (npm) ^2.0.0
@svgr/core (npm) ^8.1.0
@svgr/plugin-jsx (npm) ^8.1.0
@svgx/core (npm) ^1.0.1
@types/node (npm) ^25.0.8
@vue/compiler-sfc (npm) ^3.5.26
bumpp (npm) ^10.4.0
eslint (npm) ^9.39.2
publint (npm) ^0.3.16
rollup (npm) ^4.55.1
tsdown (npm) ^0.20.0-beta.2
tsx (npm) ^4.21.0
typescript (npm) ^5.9.3
vite (npm) ^7.3.1
vitest (npm) ^4.0.17
Files by Type (count)
TypeScript
74
JSON
37
JavaScript
30
TSX
12
HTML
12
Other (.svg)
11
CSS
10
Vue
8
Git Ignore
7
Other (.mjs)
6
YAML
5
Markdown
5
Files by Type (size)
YAML
755KB
Other (.svg)
118KB
TypeScript
45KB
Markdown
32KB
JSON
26KB
Other (.ico)
26KB
JavaScript
12KB
TSX
6KB
Vue
6KB
CSS
5KB
HTML
3KB
Other (.mjs)
3KB

The LLM identified 4 files worth highlighting for reuse:

Core module that resolves icon paths (e.g., `~icons/collection/icon`), extracts query parameters, loads SVG via Iconify's node loader (supporting custom collections and auto-install), and delegates to the appropriate compiler. It handles the full pipeline from import path to generated component code. This module is self-contained and could be extracted as a standalone icon loading utility for any build tool.

file: src/core/loader.ts ↗ | tags: #icon-loader #path-resolution #component-generation

Compiler that transforms raw SVG into a Vue 3 component using `@vue/compiler-sfc`'s `compileTemplate`. It integrates with `handleSVGId` to avoid ID collisions by generating random IDs for gradient/pattern references. The output is a `markRaw` component with a render function. This demonstrates a clean pattern for programmatic SFC generation and could be reused in other Vue 3 code generation tools.

file: src/core/compilers/vue3.ts ↗ | tags: #vue3-compiler #template-compilation #svg-id-handling

Utility that detects SVG elements referencing IDs (e.g., `url(#gradient)`) and replaces them with dynamic Vue reactive bindings that generate unique random IDs at runtime. This prevents ID collisions when multiple instances of the same icon are used on a page. The pattern is non-obvious and solves a common SVG reuse problem; it could be extracted as a standalone SVG sanitizer for any framework.

file: src/core/svgId.ts ↗ | tags: #svg-id-collision #random-id-generation #vue-reactivity

Resolver for unplugin-vue-components and unplugin-auto-import that maps component names (e.g., `IMdiAccount`) to icon import paths (`~icons/mdi/account`). It supports prefix configuration, collection aliases, custom collections, and strict matching. The resolver is a clean implementation of the unplugin resolver pattern and can be reused in any project needing auto-import of icon components.

file: src/resolver.ts ↗ | tags: #auto-import-resolver #component-name-resolution #collection-matching
Last analyzed: 2026-09-01 14:29:35.959146
Next check: 2026-10-01 14:29:35.945641
$ submit: