UNPKG

vite-plugin-single-image-format

Version:

vite-plugin-single-image-format is a Vite/Rollup plugin that converts every raster asset in your build to a single output format – webp, png or avif. It can optionally re‑compress images that are already in the target format and automatically rewrites all

28 lines (27 loc) 743 B
import { Plugin } from 'vite'; export interface WebpOptions { quality?: number; alphaQuality?: number; smartSubsample?: boolean; } export interface PngOptions { quality?: number; compressionLevel?: number; palette?: boolean; adaptiveFiltering?: boolean; } export interface AvifOptions { quality?: number; lossless?: boolean; speed?: number; } export type HtmlSizeMode = 'off' | 'add-only' | 'overwrite'; export interface SingleImageFormatOptions { format?: 'webp' | 'png' | 'avif'; reencode?: boolean; webp?: WebpOptions; png?: PngOptions; avif?: AvifOptions; htmlSizeMode?: HtmlSizeMode; } export default function singleImageFormat(userOpts?: SingleImageFormatOptions): Plugin;