astro-compressor
A gzip and brotli compressor for Astro
- Simple: Set it and forget it
- Optimal: By compressing ahead of time, a more performant compression can be performed
Table of Contents
Table of Contents
NOTE
Important: It is vital that this is the last integration in the integrations
property. Otherwise some files might not get compressed.
Quickstart
Install via your tool of choice:
npx astro add astro-compressor
yarn astro add astro-compressor
pnpm astro add astro-compressor
Then, restart the dev server by typing CTRL-C
and then npm run dev
in the terminal window that was running Astro.
Usage
First, install the package with your favorite package manager: pnpm add --dev astro-compressor
,
then configure it in your astro.config.*
file in the integrations
property:
import { defineConfig } from "astro/config";
import compressor from "astro-compressor";
export default defineConfig({
integrations: [..., compressor()],
});
Configuration
You can also optionally enable and/or disable either the gzip or brotli compression by
passing an options object to the compressor:
import { defineConfig } from "astro/config";
import compressor from "astro-compressor";
export default defineConfig({
integrations: [..., compressor({ gzip: true, brotli: false })],
});
License
MIT.