Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alloc/vite-plugin-compress
Compress your bundle + assets from Vite
https://github.com/alloc/vite-plugin-compress
vite vite-plugin
Last synced: 30 days ago
JSON representation
Compress your bundle + assets from Vite
- Host: GitHub
- URL: https://github.com/alloc/vite-plugin-compress
- Owner: alloc
- License: mit
- Created: 2021-01-25T20:56:23.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-31T16:14:28.000Z (over 2 years ago)
- Last Synced: 2024-10-31T11:37:02.490Z (about 1 month ago)
- Topics: vite, vite-plugin
- Language: TypeScript
- Homepage:
- Size: 588 KB
- Stars: 131
- Watchers: 4
- Forks: 13
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-luooooob - alloc/vite-plugin-compress - Compress your bundle + assets from Vite (TypeScript)
README
# vite-plugin-compress
[![npm](https://img.shields.io/npm/v/vite-plugin-compress.svg)](https://www.npmjs.com/package/vite-plugin-compress)
[![Code style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/alecdotbiz)> 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](https://github.com/svg/svgo)
- PNGs are further optimized with [imagemin](https://github.com/imagemin/imagemin)
- By default, files smaller than 1501 bytes are not compressed, since the [MTU](https://en.wikipedia.org/wiki/Maximum_transmission_unit) of a TCP packet is 1500 bytes
- Compatible with [vite-ssr](https://github.com/frandiox/vite-ssr)
- Just add `exclude: ["ssr-manifest.json"]`
## Usage
```ts
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](https://github.com/svg/svgo/#what-it-can-do).Default plugins include:
- `removeViewBox: false`
- `removeDimensions: true`
- Plugins listed [here](https://github.com/svg/svgo/blob/master/.svgo.yml) are enabled- `pngquant: object`
Options for the PNG optimizer.
More info [here](https://www.npmjs.com/package/imagemin-pngquant#options).- `brotli: boolean`
Set to false to disable Brotli compression.- `verbose: boolean`
Log compressed files and their compression ratios.