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]
|
assetsDir
Assets directory path
string
"/src/assets"
formats
Image formats to convert to
ImageFormat[]
['avif', 'webp']
formatOptions
Options for each format. This plugin using Sharp
behind the scene. Check the documentation for more detail about the different output options.
avif
AvifOptions
{
quality: 70,
effort: 4,
chromaSubsampling: '4:2:0'
}
webp
WebpOptions
{
quality: 90,
effort: 4,
smartSubsample: true,
nearLossless: false,
}
jpg
JpegOptions
Sharp default
png
PngOptions
Sharp default
removableExtensions
Remove files with these extensions when the conversion finishes
ImageFormat[]
[]
batchSize
Number of concurrent image processing tasks
number
4
enableScaledVariants
Generate scaled variants based on the highest-resolution image
boolean
true
enableLogs
Log generated files to the console
boolean
false
vite-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.