Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

vite-plugin-compression2

Package Overview
Dependencies
1
Maintainers
1
Versions
16
Issues
File Explorer

Advanced tools

vite-plugin-compression2

a fast vite compression plugin

    0.8.2latest
    GitHub

Version published
Maintainers
1
Weekly downloads
2,023
increased by14.29%

Weekly downloads

Changelog

Source

0.8.2

Patches

  • Fix nesting public assets can't work normal. #23

Readme

Source

vite-plugin-compression2

codecov

This is a compression plugin for vite.

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() ] })

Options

paramstypedefaultdescription
includestring | RegExp | Array<string | RegExp>-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
filenamestring[path][base].gzThe target asset filename

Q & A

Why not vite-plugin-compression

  • vite-plugin-compression no longer maintenance.

Why vite-plugin-compression2

  • vite-plugin-compression has minimal dependencies and better performance.

Can i custom the compression algorithm?

  • Yes, you can see the unit test case.

Can i generate multiple compressed assets with difference compression algorithm?

import { defineComponent } from 'vite' import { compression } from 'vite-plugin-compression2' export default defineComponent({ plugins: [ // ...your plugin compression(), compression({ algorithm: 'brotliCompress', exclude: [/\.(br)$/, /\.(gz)$/], deleteOriginalAssets: true }) ] })
  • You should set exclude for the latest compression plugin. ( Becasue in the full bundle process. Bundle chunk is shared. And there are write (delete) operations on the bundle inside the plugin. So you should ignore the compressed chunk :) If you want delete the original assets you also follow the way.

LICENSE

MIT

Author

Kanno

Keywords

FAQs

Last updated on 14 Feb 2023

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc