Socket
Book a DemoInstallSign in
Socket

astro-compressor

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astro-compressor

A gzip, brotli and zstd compressor for Astro

1.1.2
latest
Source
npmnpm
Version published
Weekly downloads
9.2K
-8.67%
Maintainers
1
Weekly downloads
 
Created
Source

astro-compressor

GitHub Actions Status npm version

A gzip, brotli and zstd compressor for Astro

  • Simple: Set it and forget it
  • Optimal: By compressing ahead of time, a more performant compression can be performed
  • All the compression: brotli, zstd, gzip, oh my
Table of Contents

Table of Contents

[!NOTE] This only works for static exports, SSR does not export assets that can be compressed ahead of time so you need to solve it with middleware. See this for more context and a partial solution.

Quickstart

Install via your tool of choice:

# Using NPM
npx astro add astro-compressor
# Using Yarn
yarn astro add astro-compressor
# Using PNPM
pnpm astro add astro-compressor

To compress your files, simply run pnpm build and look for the compression messages in the build log.

[!IMPORTANT] It is important that this is the last integration in the integrations property to ensure all the generated files are compressed.

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 })],
});

Or customize the file formats that will be compressed:

import { defineConfig } from "astro/config";
import compressor from "astro-compressor";

export default defineConfig({
  // ...
  integrations: [..., compressor({
    fileExtensions: [".html"] // only compress HTML files
  })],
});

By default, the fileExtensions array is [".css", ".js", ".html", ".xml", ".cjs", ".mjs", ".svg", ".txt"].

License

MIT.

Keywords

astro

FAQs

Package last updated on 06 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.