Vite plugin (v3.12.0) that automatically downloads and injects webfonts (Google Fonts, Bunny Fonts, Fontshare, etc.) during build and dev. It extracts font links from HTML or config, downloads CSS and font files (privacy-first, no external CDN requests at runtime), adds them to the bundle, and injects a non-render-blocking @font-face style tag. Features persistent cache (offline development), support for subset queries, custom fontsSubfolder, and various injection options. Actively maintained (multiple releases per month), supports Vite 2-8 and Rolldown, ships TypeScript types. Differentiator: zero-config and full download/injection pipeline vs alternatives like vite-plugin-google-fonts that only inject a link tag.
npm install vite-plugin-webfont-dlVerified import paths — ran on the pinned version, not inferred.
Shows basic usage with config: pass font CSS URL(s) and optional settings like inject position and subfolder.
Delete node_modules/.cache/vite-plugin-webfont-dl or run vite with --force.
Add font link tags in index.html or use simple config with explicit CSS URLs.
Set throwErrors: true to get explicit errors during build.
Run 'npm install vite flat-cache --save-dev' or ensure your package manager installs peer dependencies.
Delete the cache folder and rebuild: rm -rf node_modules/.cache/vite-plugin-webfont-dl && npm run build.
Install with 'npm i vite-plugin-webfont-dl -D' and ensure import is default: import webfontDownload from 'vite-plugin-webfont-dl'.