compression(options?)
ts
compression({
algorithms: ["gzip", "brotli"],
threshold: 10 * 1024,
minRatio: 0.95,
});| Option | Default | Description |
|---|---|---|
algorithms | gzip + Brotli | One algorithm or an array |
threshold | 1024 | Minimum original byte count |
minRatio | 0.95 | Maximum compressed/original size ratio |
filter | Common text/wasm | RegExp or function filter |
fileName | .gz / .br | Custom safe, nonconflicting relative filename |
gzipOptions / brotliOptions | Node defaults | Options passed to node:zlib |
The server must still select generated resources according to Accept-Encoding.
compression Compress
Generates .gz/.br precompressed outputs for static serving by Nginx, Caddy, or object storage.
Signature
ts
export function compression(options: CompressionPluginOptions = {}): Plugin;Example
ts
import { compression } from "fast-vite-plugins";
const plugin = compression({ algorithms: ["gzip", "brotli"], threshold: 1024 });
export default { plugins: [plugin] };Input
| Input | Type | Required / default | Description |
|---|---|---|---|
options | CompressionPluginOptions | Optional; defaults to {} | Algorithms, thresholds, size ratios, filters, and encoder options. |
Returns
| Value | Type | Description |
|---|---|---|
plugin | Plugin | Precompression plugin for Vite plugins. |
