svgIcons(options?)
Compiles an SVG directory into individual Vue TSX components and a root index. Each SVG becomes SVG-relative-path/index.tsx beside the root index, using defineComponent and inline SVG JSX. Consumers must enable Vue JSX/TSX transforms.
ts
svgIcons({
dir: "src/assets/icons",
output: "src/icons/index.ts",
componentPrefix: "App",
removeDimensions: true,
defaultAttributes: { "aria-hidden": "true", focusable: false },
});| Option | Default | Description |
|---|---|---|
dir | "src/assets/icons" | SVG source directory |
output | "src/icons/index.ts" | Icon root index |
deep | true | Recursive scanning |
componentPrefix | "" | Component-name prefix |
componentSuffix | "" | Component-name suffix |
include / name | - | File filter / naming callback |
defaultAttributes | {} | Default root attributes; source SVG attributes take precedence |
removeDimensions | false | Remove width/height |
debounce | 80 | Development watch debounce in milliseconds |
SVG markup is written directly into generated TSX. Do not scan user uploads or other untrusted SVGs.
The root index provides named exports and directly default-exports a readonly component object with export default { ... } as const; no intermediate icons variable is generated.
svgIcons Icons
Compiles an SVG directory into individual Vue icon components and a root index.
Generated components use defineComponent and inline SVG JSX; consumers need Vue JSX/TSX transforms.
Signature
ts
export function svgIcons(options: SvgIconsPluginOptions = {}): Plugin;Example
ts
import { svgIcons } from "fast-vite-plugins";
const plugin = svgIcons({ dir: "src/assets/icons", output: "src/icons/index.ts" });
export default { plugins: [plugin] };Input
| Input | Type | Required / default | Description |
|---|---|---|---|
options | SvgIconsPluginOptions | Optional; defaults to {} | SVG directory, outputs, naming, filters, and root attributes. |
Returns
| Value | Type | Description |
|---|---|---|
plugin | Plugin | SVG icon generation plugin for Vite plugins. |
