Frontend Development 5 min read

Rapid Icon Library Toolchain for Vue and React with Varlet

This article introduces a comprehensive toolchain that quickly builds internal or open‑source icon libraries, converting SVGs into Vue 3 and React components, web fonts, and modules, while supporting Figma integration, automatic component import, and full release workflows.

Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Rapid Icon Library Toolchain for Vue and React with Varlet

The author, haoziqaq, creator of the Varlet component library, introduces a new toolchain for quickly building internal or open‑source icon libraries, originally created for the Varlet official icon set.

Features include converting SVG icon sets into Vue 3 and React components, generating ESM/CJS modules, producing web fonts, supporting automatic component import via unplugin‑vue‑components, providing a built‑in icon preview site, fetching SVGs directly from Figma files, and offering release utilities for npm and git.

Icon usage examples show how to import the generated SVG font CSS and use font icons, as well as how to use the generated Vue and React components with optional color and size props.

Automatic component import is demonstrated by configuring vite.config.ts with unplugin-vue-components and the provided XIconResolver to auto‑import icon components.

Framework support defaults to Vue 3; to generate React components, set framework: 'react' in the configuration and adjust peer dependencies accordingly.

Fetching icons from Figma involves creating a Figma file named "Icons", obtaining its file ID and access token, and configuring the token in the script (recommended via CI environment variables).

CI integration can be achieved by using a Figma webhook to trigger rebuilds whenever designers update the icon library.

Core commands include pnpm dev (start preview site), pnpm build (build preview site), pnpm preview (preview mode), pnpm icons:build (build web font), pnpm icons:generate (generate components and modules), pnpm icons:figma (fetch SVGs from Figma), and pnpm release (publish the icon library).

The article concludes by encouraging readers to contribute via PRs, issues, or stars, and provides links to the Varlet component library and the icon library starter template repositories.

frontendreactVueFigmaToolchainicon libraryvarlet
Rare Earth Juejin Tech Community
Written by

Rare Earth Juejin Tech Community

Juejin, a tech community that helps developers grow.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.