一覧へ戻る
rogerleung0411/unplugin-compress(新しいタブで開きます)
主要言語: TypeScript
A Universal Compress Plugin for Webpack / Vite / Rollup.
- star 数
- 2
- watcher 数
- 1
- fork 数
- 0
- issue 数
- 0
- 最終更新
- 2021/11/02
主要言語: TypeScript
A Universal Compress Plugin for Webpack / Vite / Rollup.
A universal compress plugin for Webpack / Vite / Rollup, powered by Unplugin, generating compressed file using gzip / brotli / etc...
See more usage example in folder
/examples. Feel free to modify and play it on your own!
// webpack.config.js const compress = require('unplugin-compress/webpack'); module.exports = ({ mode: 'production', entry: './src/index.js', output: { path: distPath, }, plugins: [ compress({ filter: /\.js$/, }), compress({ filter: /main\.js$/, algorithm: 'brotliCompress', extname: '.br', }), // etc... ] });
// in vite.config.ts import { defineConfig } from 'vite'; import compress from 'unplugin-compress/vite'; export default defineConfig({ plugins: [ compress({ filter: /\.js$/, }), compress({ filter: /\.(js|css)$/, algorithm: 'brotliCompress', extname: '.br', }), ] });
// in rollup.config.js import compress from 'unplugin-compress/rollup'; export default { // ... plugins: [ compress({ filter: /\.js$/, }) ], // ... };
| Key | Type | Default | Description |
|---|---|---|---|
| verbose | boolean |
true |
Whether to output the compressed result in the console |
| filter | RegExp | (filename: string) => boolean |
() => false |
Distinguish whether a chunk/asset should be compressed or not. If filter is undefined, nothing will be compressed. |
| algorithm | Algorithm |
gzip |
Possible values are gzip, brotliCompress, deflate and deflateRaw |
| extname | string |
.gz |
The extension name of output file |
| threshold | number |
0 |
Only assets bigger than this size are processed (in bytes) |