Vite plugin for automatic image conversion to WebP and AVIF during dev server runtime. Current version 2.2.1, supports Vite 4.x–8.x and Nuxt setups with srcDir. Key differentiator: real-time conversion on file addition via chokidar watchers, skips existing targets, runs WebP and AVIF in parallel. Requires sharp and chokidar as peer dependencies.
npm install vite-webp-avif-generator-pluginNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows minimal plugin setup with custom watched folders and exclusion, enabling AVIF conversion.
Upgrade Node.js to >=20.19.0 or pin to Vite 6.x and lower Node requirement accordingly.
Use different image optimization for production builds (e.g., vite-plugin-imagemin).
Use absolute paths or ensure correct relative references; see README path resolution section.
Upgrade to latest plugin version or lock sharp and chokidar accordingly.
Do not rely on exclude for generated files; the plugin already handles it.
npm install -D sharp
The plugin already uses apply: 'serve' internally; ensure not to override apply in config.
import convertImages from 'vite-webp-avif-generator-plugin' (no braces)