RSBuild Plugin Iconify

May 30, 2025 ยท View on GitHub

A RSBuild plugin that automatically generates optimized CSS with embedded SVG icons from Iconify.

Features

  • ๐Ÿš€ Automatically scan your code for icon usage
  • ๐ŸŽฏ Generate optimized SVG data URIs for icons
  • ๐Ÿ”„ Include complete icon sets or only used icons
  • ๐Ÿ“ฆ Compress and optimize the final CSS
  • ๐Ÿ”Œ Seamless integration with RSBuild

Installation

npm install rsbuild-plugin-iconify --save-dev
# or
yarn add rsbuild-plugin-iconify -D
# or
bun add -D rsbuild-plugin-iconify

Usage

Add the plugin to your RSBuild configuration:

// rsbuild.config.js
import { pluginIconify } from 'rsbuild-plugin-iconify'

export default {
	plugins: [
		pluginIconify({
			// Options (all optional)
			targetDir: 'src/styles/icons', // Directory to save generated CSS
			includeSets: ['mdi-light', 'material-symbols'], // Icon sets to include completely
			maxIconsPerSet: 200, // Max icons per included set
			maxTotalIcons: 1000, // Max total icons
			compress: true, // Apply compression
		}),
	],
}

Import the generated CSS in your main CSS file:

@import './styles/icons/generated-icons.css';

Use the icons in your components:

// With CSS classes
<span className="icon-[mdi-light--home] iconify"/>

// For colored icons
<span className="icon-[material-symbols--edit] iconify-color"/>

Options

OptionTypeDefaultDescription
targetDirstring'src/styles/icons'Directory to save generated CSS
includeSetsstring[]['mdi-light', 'material-symbols']Icon sets to include completely
maxIconsPerSetnumber200Maximum icons per included set
maxTotalIconsnumber1000Maximum total icons
compressbooleantrueApply compression to CSS

License

MIT