vite-plugin-compress
TypeScript icon, indicating that this package has built-in type declarations

2.1.1 • Public • Published

vite-plugin-compress

npm Code style: Prettier Donate

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"]

 

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.

Package Sidebar

Install

npm i vite-plugin-compress

Weekly Downloads

899

Version

2.1.1

License

MIT

Unpacked Size

28.2 kB

Total Files

10

Last publish

Collaborators

  • aleclarson