This Vite plugin converts images to WebP format and updates their paths in HTML and CSS files.
npm install vite-plugin-webp-and-path
In your vite.config.js:
import VitePluginWebpAndPath from 'vite-plugin-webp-and-path';
export default {
plugins: [
VitePluginWebpAndPath({
// options
}),
],
};
targetDir
: Target directory to search for image files. Default is./dist/
.imgExtensions
: Comma-separated list of image file extensions to convert. Default isjpg,png
.textExtensions
: Comma-separated list of text file extensions to update image paths in. Default ishtml,css
.quality
: Quality of the converted WebP images. Default is 80.enableLogs
: Enable logs. Default is true.
MIT