Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/XeryYue/vite-compression-plugin
vite plugin. compress your bundle file.
https://github.com/XeryYue/vite-compression-plugin
compression vite-compression vite-plugin
Last synced: about 1 month ago
JSON representation
vite plugin. compress your bundle file.
- Host: GitHub
- URL: https://github.com/XeryYue/vite-compression-plugin
- Owner: nonzzz
- License: mit
- Created: 2022-01-31T13:28:18.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-18T08:53:31.000Z (5 months ago)
- Last Synced: 2024-05-02T02:53:03.656Z (5 months ago)
- Topics: compression, vite-compression, vite-plugin
- Language: TypeScript
- Homepage:
- Size: 2.82 MB
- Stars: 122
- Watchers: 1
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- fucking-awesome-vite - vite-compression-plugin - Use Node.js stream compress file to gzip or more. (Plugins / Framework-agnostic Plugins)
- awesome-vite - vite-compression-plugin - Use Node.js stream compress file to gzip or more. (Plugins / Framework-agnostic Plugins)
README
[![codecov](https://codecov.io/gh/nonzzz/vite-plugin-compression/branch/master/graph/badge.svg?token=NG4475OP6B)](https://codecov.io/gh/nonzzz/vite-compression-plugin)
## Install
```bash
$ yarn add vite-plugin-compression2 -D# or
$ npm install vite-plugin-compression2 -D
```## Usage
```js
import { defineConfig } from 'vite'import { compression } from 'vite-plugin-compression2'
export default defineConfig({
plugins: [
// ...your plugin
compression()
]
})
```## Options
| params | type | default | description |
| ---------------------- | --------------------------------------------- | --------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| `include` | `string \| RegExp \| Array` | `/\.(html\|xml\|css\|json\|js\|mjs\|svg|yaml|yml|toml)$/` | Include all assets matching any of these conditions. |
| `exclude` | `string \| RegExp \| Array` | `-` | Exclude all assets matching any of these conditions. |
| `threshold` | `number` | `0` | Only assets bigger than this size are processed (in bytes) |
| `algorithm` | `string\| function` | `gzip` | The compression algorithm |
| `compressionOptions` | `Record` | `{}` | Compression options for `algorithm`(details see `zlib module`) |
| `deleteOriginalAssets` | `boolean` | `false` | Whether to delete the original assets or not |
| `skipIfLargerOrEqual` | `boolean` | `true` | Whether to skip the compression if the result is larger than or equal to the original file |
| `filename` | `string` | `[path][base].gz` | The target asset filename |## Q & A
[FAQ](./Q&A.md)
### Others
- If you want to analysis your bundle assets. Maybe you can try [vite-bundle-analyzer](https://github.com/nonzzz/vite-bundle-analyzer)
- `tarball` option `dest` means to generate a tarball somewhere
- `tarball` is based on the `ustart`. It should be compatible with all popular tar distributions out there (gnutar, bsdtar etc)
### Sponsors
### LICENSE
[MIT](./LICENSE)
### Author
Kanno