A Vite plugin that automatically generates favicons in various formats and sizes from a source image using the Favicons library. Version 0.1.7 is stable, with a moderate release cadence. It integrates seamlessly into the Vite build pipeline, provides a virtual module 'virtual:favicons' for injecting links, includes caching for faster builds, and ships TypeScript definitions. Key differentiators: designed specifically for Vite, works with SvelteKit (unlike some alternatives), and offers a simple API with optional customization via Favicons package options.
npm install vite-plugin-faviconsVerified import paths — ran on the pinned version, not inferred.
Shows how to configure the plugin in vite.config.ts and use the virtual module to inject favicon links into HTML head.
Upgrade Vite to ^6.3.5 and TypeScript to ^5.8.3.
In Svelte: import { FaviconsHead } from 'virtual:favicons' and use {@html FaviconsHead}. In other frameworks, import the default export.Monitor release notes for option name changes.
Ensure imgSrc points to an existing file; verify with a console.log or check the build output.
Run 'npm install favicons' alongside 'vite-plugin-favicons'.
Use ESM imports (import) instead of require().
Use import { faviconsPlugin } from 'vite-plugin-favicons' instead of import faviconsPlugin from 'vite-plugin-favicons'.Convert your project to ESM (add "type": "module" in package.json) or use dynamic import().
Pass an options object with at least 'imgSrc' property, e.g., faviconsPlugin({ imgSrc: './src/assets/favicon.png' }).Install the 'favicons' package: npm install favicons.
Add a declaration file (e.g., env.d.ts) with: declare module 'virtual:favicons' { const links: string; export default links; }