gzip for astro static sites
https://zokki.net
.vscode | ||
src | ||
.gitignore | ||
.npmignore | ||
.prettierrc | ||
LICENSE | ||
package-lock.json | ||
package.json | ||
README.md | ||
tsconfig.json |
@zokki/astro-gzip
This integration finds files matching the specified extensions within the Astro build output directory and compresses them using GZip.
Note
astro-gzip
only for statically generated build and pre-rendered routes.
Why
Gzip compression can significantly reduce the size of your web assets, leading to faster page loads and improved user experience. 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.
Installation
-
Install with npm.
npm install @zokki/astro-gzip
-
Import into the astro-config. The integration should be the last one in the array.
import { gzip } from '@zokki/astro-gzip'; export default defineConfig({ integrations: [gzip()], });
Configuration
/**
* Toggle logging of all gzipped files
*
* @default true
*/
logAllFiles?: boolean;
/**
* Which extension should be gzipped
*
* @default ['css', 'js', 'html', 'xml', 'cjs', 'mjs', 'svg', 'txt']
*/
extensions?: string[];
/**
* Options for the zipping
*
* @default { level: 9 }
*/
zlibOptions?: ZlibOptions;
License
MIT © Tim-Niclas Oelschläger