Package Exports
- vite-plugin-compression
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vite-plugin-compression) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
vite-plugin-imagemin
English | 中文
Use gzip or brotli to compress resources.
Since vite-plugin-compress does not support gzip compression, a separate copy has been modified and some functions have been added.
Install (yarn or npm)
node version: >=12.0.0
vite version: >=2.0.0-beta.68
yarn add vite-plugin-compression -Dor
npm i vite-plugin-compression -DUsage
- Configuration plugin in vite.config.ts
import viteCompression from 'vite-plugin-compression';
export default () => {
return {
plugins: [viteCompression()],
};
};Options
| params | type | default | default |
|---|---|---|---|
| verbose | boolean |
true |
Whether to output the compressed result in the console |
| filter | RegExp or (file: string) => boolean |
- | Specify which resources are not compressed |
| disable | boolean |
false |
Whether to disable |
| threshold | number |
- | It will be compressed if the volume is larger than threshold, the unit is kb |
| algorithm | string |
gzip |
Compression algorithm, optional ['gzip','brotliCompress' ,'deflate','deflateRaw'] |
| ext | string |
.gz |
Suffix of the generated compressed package |
| compressionOptions | object |
- | The parameters of the corresponding compression algorithm |
| deleteOriginFile | boolean |
- | Whether to delete source files after compression |
Example
Run Example
cd ./example
yarn install
yarn test:gzip
yarn test:br
Sample project
License
MIT