Vite plugin (v0.0.5) that generates low-quality image placeholders (LQIP) using WebP compression via sharp. It inlines a tiny base64-encoded placeholder image (<1kB) to enable instant loading and reduce layout shift. Compatible with any Vite-powered framework (React, Svelte, Vue, Astro). The plugin does not alter source images, so it can be composed with vite-imagetools for full optimization. Uses a similar technique to lqip-modern but with custom sharp options. Releases are patch-level; current version is 0.0.5. It is not yet stable (pre-v1.0). TypeScript types are included.
npm install vite-plugin-lqipVerified import paths — ran on the pinned version, not inferred.
Shows how to configure the plugin in vite.config.js and use the ?lqip import in a React component to render an image with an inline LQIP placeholder, reducing layout shift.
Use separate imports for LQIP and for imagetools transformations: import lqip from './image.jpg?lqip'; import srcSet from './image.jpg?w=500;700&format=webp';
Add vite-imagetools to your Vite config. Ensure vite-plugin-lqip is placed before vite-imagetools in the plugins array.
Monitor releases for breaking changes to the sharp configuration object.
Add the declaration shown in the README to your project's globals.d.ts.
If sharp installation fails, see sharp's documentation for platform-specific instructions.
npm install sharp
Add the type declaration: declare module '*?lqip' { ... } in a .d.ts file.Use import lqip from 'vite-plugin-lqip' instead of import { lqip } from 'vite-plugin-lqip'.Ensure the package is installed: npm i -D vite-plugin-lqip