gzip for astro static sites https://zokki.net
Go to file
2025-02-06 23:23:57 +01:00
.vscode v1.0.0 2024-04-13 16:58:22 +02:00
src fix: loggin name 2024-04-13 17:28:39 +02:00
.gitignore v1.0.0 2024-04-13 16:58:22 +02:00
.npmignore v1.0.0 2024-04-13 16:58:22 +02:00
.prettierrc v1.0.0 2024-04-13 16:58:22 +02:00
LICENSE v1.0.0 2024-04-13 16:58:22 +02:00
package-lock.json v1.0.3 2024-04-15 23:15:57 +02:00
package.json v1.0.3 2024-04-15 23:15:57 +02:00
README.md chore: 'why'-section for README 2025-02-06 23:23:57 +01:00
tsconfig.json v1.0.0 2024-04-13 16:58:22 +02:00

@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

  1. Install with npm.

    npm install @zokki/astro-gzip
    
  2. 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