Compress

screenshot of Compress

Compress

Overview

The Compress integration for Astro brings compression utilities to Astro projects, allowing for automatic compression of CSS, HTML, SVG, JavaScript, and image files in the Astro outDir folder. This integration provides options to override default settings, filter files, control logging level, and more.

Features

  • Compression Utilities: Automatically compress CSS, HTML, SVG, JavaScript, and image files.
  • Customization: Override default compression options for CSS, lightningcss, html-minifier-terser, sharp, svgo, and terser.
  • Multiple Paths: Easily specify multiple paths or directories to compress.
  • File Filtering: Exclude specific files from compression based on regular expressions or file names.
  • Logging Control: Set the logging level to customize the amount of debug messages.

Using Astro CLI:

astro add Compress

Manually Install:

npm install @astro/compress

Then apply the integration in astro.config.ts file.

// astro.config.ts
{
  integrations: ['@astro/compress'],
}

Summary

The Compress integration for Astro provides a convenient way to compress CSS, HTML, SVG, JavaScript, and image files in an Astro project. With options for customization, logging control, and file filtering, developers can optimize their project build by integrating Compress in the project setup.