@neosjs/unplugin-imagemin
v0.0.2
Published
基于squoosh和sharp的图像压缩插件
Downloads
9
Maintainers
Readme
@neosjs/unplugin-imagemin
安装
pnpm add @neosjs/unplugin-imagemin@latest -D
使用方法
基础使用
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ImageMin from '@neosjs/unplugin-imagemin/vite'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), ImageMin()],
})
高级使用
import path from 'node:path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ImageMin from '@neosjs/unplugin-imagemin/vite'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
ImageMin({
mode: 'squoosh',
compress: {
jpg: {
quality: 10,
},
jpeg: {
quality: 10,
},
png: {
quality: 10,
},
webp: {
quality: 10,
},
},
conversion: [
{ from: 'jpeg', to: 'webp' },
{ from: 'png', to: 'webp' },
{ from: 'JPG', to: 'jpeg' },
],
}),
],
})