Home

Awesome

<p align="center"> <img src="https://socialify.git.ci/nonzzz/vite-plugin-compression/image?description=1&font=KoHo&language=1&logo=https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F65625612%3Fs%3D200%26v%3D4&name=1&owner=1&pattern=Solid&theme=Auto" width="640" height="320" /> </p>

codecov

Install

$ yarn add vite-plugin-compression2 -D

# or

$ npm install vite-plugin-compression2 -D

Usage

import { defineConfig } from 'vite'

import { compression } from 'vite-plugin-compression2'

export default defineConfig({
  plugins: [
    // ...your plugin
    compression()
    // If you want to create a tarball archive you can import tarball plugin from this package and use
    // after compression.
  ]
})

Options

paramstypedefaultdescription
includestring | RegExp | Array<string | RegExp>/\.(html|xml|css|json|js|mjs|svg|yaml|yml|toml)$/Include all assets matching any of these conditions.
excludestring | RegExp | Array<string | RegExp>-Exclude all assets matching any of these conditions.
thresholdnumber0Only assets bigger than this size are processed (in bytes)
algorithmstring| functiongzipThe compression algorithm
compressionOptionsRecord<string,any>{}Compression options for algorithm(details see zlib module)
deleteOriginalAssetsbooleanfalseWhether to delete the original assets or not
skipIfLargerOrEqualbooleantrueWhether to skip the compression if the result is larger than or equal to the original file
filenamestring[path][base].gzThe target asset filename

Q & A

FAQ

Others

Sponsors

<p align="center"> <a href="https://cdn.jsdelivr.net/gh/nonzzz/sponsors/sponsorkit/sponsors.svg"> <img src="https://cdn.jsdelivr.net/gh/nonzzz/sponsors/sponsorkit/sponsors.svg"/> </a> </p>

LICENSE

MIT

Acknowledgements

NWYLZW

Author

Kanno