Compress
AstroCompress is an Astro integration that brings compression utilities to your Astro project. It allows for the compression of CSS, HTML, JavaScript, images, and SVG files in the Astro outDir folder. It is important to note that AstroCompress will only compress the statically generated build and pre-rendered routes, not requests. To achieve the best optimization, AstroCompress should be used as the last integration in the integration list.
There are two ways to add AstroCompress to your project.
astro add
commandRun the following command from your project directory:
npm install astrocompress
yarn add astrocompress
pnpm add astrocompress
Follow the prompts to install the necessary dependencies and update your astro.config.* file to apply the integration.
Install the AstroCompress integration by running npm install astrocompress
or yarn add astrocompress
or pnpm add astrocompress
.
In your astro.config.* file, apply the integration using the integrations property:
import {astrocompress} from 'astrocompress';
export default {
// ...
integrations: [astrocompress()],
// ...
};
AstroCompress is a powerful integration for Astro projects that brings compression utilities to optimize CSS, HTML, JavaScript, images, and SVG files. It provides various customization options, support for multiple paths and file filtering, as well as logging control. By using AstroCompress wisely, you can significantly improve the performance and loading speed of your Astro project.