astro-brotli/README.md

60 lines
1.4 KiB
Markdown

# @zokki/astro-brotli
This integration finds files matching the specified extensions within the Astro build output directory and compresses them using brotli.
> **Note**
>
> `astro-brotli` only for statically generated build and pre-rendered routes.
## Why
Brotli compression provides better compression ratios compared to gzip and deflate, resulting in smaller file sizes for web assets. This integration automatically handles the compression of static files during the build process, saving you bandwidth and eliminating the need for server-side compression configuration. This leads to:
- Faster page loads
- Reduced bandwidth usage
- Better user experience
- Improved SEO performance
## Installation
1. Install with npm.
```bash
npm install @zokki/astro-brotli
```
2. Import into the astro-config. The integration should be the last one in the array.
```ts
import { brotli } from '@zokki/astro-brotli';
export default defineConfig({
integrations: [brotli()],
});
```
## Configuration
```ts
/**
* Toggle logging of all compressed files
*
* @default true
*/
logAllFiles?: boolean;
/**
* Which extension should be compressed
*
* @default ['css', 'js', 'html', 'xml', 'cjs', 'mjs', 'svg', 'txt']
*/
extensions?: string[];
/**
* Options for brotli compression
*/
brotliOptions?: BrotliOptions;
```
## License
[MIT](LICENSE) © Tim-Niclas Oelschläger