A Vite plugin that automatically converts your raster images into modern formats and responsive variants β with zero hassle.
Added 3 image and 2 more 1 seconds laterIf you include high-density assets like [email protected] or [email protected], the plugin will:
@3x β @2x β @1x, @2x β @1x, depending on max scale).WebP and AVIF formats.Creates a tiny blurred webp thumbnail perfect for lazy-loading or progressive image effects.
Handles multiple images in parallel for maximum performance.
Install, enable, and enjoy optimized images instantly.
npm install vite-convert-images --save-dev
// vite.config.ts
import { defineConfig } from 'vite'
import viteConvertImages from 'vite-convert-images'
export default defineConfig({
plugins: [
viteConvertImages()
]
})
If you save your image in assets folder it will generate all the conversions
βοΈImportnat Note
Images name must be end with @2x, @3x, @4x etc. because the conversions count depends on this number.
For example
| Input File | Generated Assets |
| ------------------ | -------------------------------------------------------- |
| [email protected] | [email protected], [email protected], hero@2x.*, hero@1x.*, [email protected] |
| [email protected] | [email protected], [email protected], icon@1x.*, [email protected] |
assetsDirAssets directory path
string"/src/assets"formatsImage formats to convert to
ImageFormat[]['avif', 'webp']formatOptionsOptions for each format. This plugin using Sharp behind the scene. Check the documentation for more detail about the different output options.
avifAvifOptions{
quality: 70,
effort: 4,
chromaSubsampling: '4:2:0'
}
webpWebpOptions{
quality: 90,
effort: 4,
smartSubsample: true,
nearLossless: false,
}
jpgJpegOptionsSharp defaultpngPngOptionsSharp defaultremovableExtensionsRemove files with these extensions when the conversion finishes
ImageFormat[][]batchSizeNumber of concurrent image processing tasks
number4enableScaledVariantsGenerate scaled variants based on the highest-resolution image
booleantrueenableLogsLog generated files to the console
booleanfalsevite-convert-images uses Viteβs watchChange
hook to detect when image files are added, modified or removed.
This means:
π§© Image conversion runs only while the Vite dev server is active.
β‘ It processes new or updated images on the fly β no need to restart the server.
This approach ensures that the plugin:
Doesnβt slow down your production builds
Keeps development feedback loops instant and responsive
Provides a live, automatic image pipeline while you work
Modern web performance starts with images. vite-convert-images helps you ship smaller, smarter, and future-proof image assets without any manual work.
MIT License Β© 2025 feat.