UNPKG

vue-icon-gallery

Version:

Vite plugin for Vue 3 that opens a local gallery to preview your SVG icons before using them in templates. Instantly browse, search, and view your icons directly from your dev server — no more guessing by file name.

31 lines (30 loc) 1.17 kB
import { startGalleryServer, stopGalleryServer } from './simpleGalleryServer.js'; /** * Vite plugin that creates a local gallery server to preview SVG icons */ export function vueIconGallery(options) { const { iconsPath, port = 3002, open = true } = options; // Validate iconsPath if (!iconsPath || (Array.isArray(iconsPath) && iconsPath.length === 0)) { throw new Error('[vue-icon-gallery] iconsPath is required. Please provide a path or array of paths to your icon folders.'); } return { name: 'vite-plugin-vue-icon-gallery', apply: 'serve', // Only run in dev mode async configureServer() { // Start the gallery server when Vite dev server starts await startGalleryServer({ iconsPath, port, open }); }, async closeBundle() { // Stop the gallery server when Vite closes await stopGalleryServer(); } }; } // Re-export utilities for advanced usage export { scanIcons } from './iconScanner.js'; export { startGalleryServer, stopGalleryServer } from './simpleGalleryServer.js';