vite-plugin-compress
v2.1.1
Published
Compress your bundle + assets from Vite
Downloads
1,713
Maintainers
Readme
vite-plugin-compress
Compress your bundle + assets from Vite
- Assets generated by Vite and assets from
./public
are compressed with Brotli - Images, sounds, WOFF2 fonts, and PDFs are not compressed with Brotli, since these formats are compressed by default
- SVGs are further optimized with svgo
- PNGs are further optimized with imagemin
- By default, files smaller than 1501 bytes are not compressed, since the MTU of a TCP packet is 1500 bytes
- Compatible with vite-ssr
- Just add
exclude: ["ssr-manifest.json"]
- Just add
Usage
import compress from 'vite-plugin-compress'
export default {
plugins: [
compress(),
]
}
Options
quality: number
Higher quality means smaller file sizes.
Defaults to max quality (11).threshold: number
Minimum file size (in bytes) to be compressed.
Defaults to 1501.exclude: string[]
Globs to exclude certain files from being compressed.extensions: string[]
Additional extensions to compress with Brotli.Default extensions include:
.html
.js
.css
.svg
.json
svgo: object
Options for the SVG optimizer.
More info here.Default plugins include:
removeViewBox: false
removeDimensions: true
- Plugins listed here are enabled
pngquant: object
Options for the PNG optimizer.
More info here.brotli: boolean
Set to false to disable Brotli compression.verbose: boolean
Log compressed files and their compression ratios.