{"id":37181411,"url":"https://github.com/kamranahmedse/astro-compress","last_synced_at":"2026-01-22T00:00:50.195Z","repository":{"id":187072584,"uuid":"676242848","full_name":"kamranahmedse/astro-compress","owner":"kamranahmedse","description":"🗜️ AstroJS compression utilities. Compress CSS, HTML, JavaScript and more!","archived":false,"fork":true,"pushed_at":"2023-08-08T20:17:40.000Z","size":993,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-01T20:29:22.915Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"PlayForm/Compress","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kamranahmedse.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-08T18:52:48.000Z","updated_at":"2024-05-01T20:29:22.916Z","dependencies_parsed_at":"2023-08-08T22:14:52.903Z","dependency_job_id":null,"html_url":"https://github.com/kamranahmedse/astro-compress","commit_stats":null,"previous_names":["kamranahmedse/astro-compress"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kamranahmedse/astro-compress","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamranahmedse%2Fastro-compress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamranahmedse%2Fastro-compress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamranahmedse%2Fastro-compress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamranahmedse%2Fastro-compress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kamranahmedse","download_url":"https://codeload.github.com/kamranahmedse/astro-compress/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamranahmedse%2Fastro-compress/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28647471,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T21:29:11.980Z","status":"ssl_error","status_checked_at":"2026-01-21T21:24:31.872Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T21:00:24.729Z","updated_at":"2026-01-22T00:00:50.180Z","avatar_url":"https://github.com/kamranahmedse.png","language":"TypeScript","readme":"\u003ch2\u003e\u003cpicture\u003e\u003csource media=\"(prefers-color-scheme: dark)\" srcset=https://raw.githubusercontent.com/ImageRepository/logos/main/.github/Image/logomark-dark.svg\u003e\u003csource media=\"(prefers-color-scheme: light)\" srcset=https://raw.githubusercontent.com/ImageRepository/logos/main/.github/Image/logomark-light.svg\u003e\u003cimg src=https://raw.githubusercontent.com/ImageRepository/logos/main/.github/Image/logomark-light.svg alt=Astro width=28\u003e\u003c/picture\u003e\u003cspan\u003e\u0026nbsp;\u003c/span\u003eRelated\u003c/h2\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd colspan=1 valign=top\u003e\u003cbr\u003e\u003ca href=https://github.com/astro-community/astro-critters/actions/workflows/node.yml target=_blank\u003e\u003cpicture\u003e\u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/github/actions/workflow/status/astro-community/astro-critters/node.yml?branch=main\u0026amp;label=Build\u0026amp;logo=node.js\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/github/actions/workflow/status/astro-community/astro-critters/node.yml?branch=main\u0026amp;label=Build\u0026amp;logo=node.js\u0026amp;color=white\u0026amp;logoColor=black\u0026amp;labelColor=white\u0026amp;logoWidth=15\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/astro-community/astro-critters/node.yml?branch=main\u0026amp;label=Build\u0026amp;logo=node.js\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003c/picture\u003e\u003c/a\u003e\u003cbr\u003e\u003ca href=https://npmjs.org/astro-critters target=_blank\u003e\u003cpicture\u003e\u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/npm/v/astro-critters?label=Version\u0026amp;logo=npm\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/npm/v/astro-critters?label=Version\u0026amp;logo=npm\u0026amp;color=white\u0026amp;logoColor=black\u0026amp;labelColor=white\u0026amp;logoWidth=15\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/astro-critters?label=Version\u0026amp;logo=npm\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003c/picture\u003e\u003c/a\u003e\u003cbr\u003e\u003ca href=https://npmjs.org/astro-critters target=_blank\u003e\u003cpicture\u003e\u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/librariesio/release/npm/astro-critters?label=Dependencies\u0026amp;logo=dependabot\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/librariesio/release/npm/astro-critters?label=Dependencies\u0026amp;logo=dependabot\u0026amp;color=white\u0026amp;logoColor=black\u0026amp;labelColor=white\u0026amp;logoWidth=15\"\u003e\u003cimg src=\"https://img.shields.io/librariesio/release/npm/astro-critters?label=Dependencies\u0026amp;logo=dependabot\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003c/picture\u003e\u003c/a\u003e\u003cbr\u003e\u003ca href=https://npmjs.org/astro-critters target=_blank\u003e\u003cpicture\u003e\u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/npm/dw/astro-critters?label=Downloads\u0026amp;logo=npm\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/npm/dw/astro-critters?label=Downloads\u0026amp;logo=npm\u0026amp;color=white\u0026amp;logoColor=black\u0026amp;labelColor=white\u0026amp;logoWidth=15\"\u003e\u003cimg src=\"https://img.shields.io/npm/dw/astro-critters?label=Downloads\u0026amp;logo=npm\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003c/picture\u003e\u003c/a\u003e\u003cbr\u003e\u003cbr\u003e\u003c/td\u003e\u003ctd colspan=1 valign=top\u003e\u003cbr\u003e\u003ca href=https://github.com/astro-community/astro-critters target=_blank\u003e\u003cpicture\u003e\u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/github/stars/astro-community/astro-critters?label=stars\u0026amp;logo=github\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/github/stars/astro-community/astro-critters?label=stars\u0026amp;logo=github\u0026amp;color=white\u0026amp;logoColor=black\u0026amp;labelColor=white\u0026amp;logoWidth=15\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/astro-community/astro-critters?label=stars\u0026amp;logo=github\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003c/picture\u003e\u003c/a\u003e\u003cbr\u003e\u003ca href=https://github.com/astro-community/astro-critters target=_blank\u003e\u003cb\u003eastro-critters\u003c/b\u003e\u003c/a\u003e\u003cbr\u003e\u003cb\u003e🦔 AstroJS GoogleChromeLabs critters integration.\u003cbr\u003eInline your critical CSS with Astro.\u003cbr\u003e\u003c/b\u003e\u003c/td\u003e\u003ctd colspan=1 valign=top\u003e\u003cbr\u003e\u003ca href=https://github.com/astro-community/astro-rome/actions/workflows/node.yml target=_blank\u003e\u003cpicture\u003e\u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/github/actions/workflow/status/astro-community/astro-rome/node.yml?branch=main\u0026amp;label=Build\u0026amp;logo=node.js\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/github/actions/workflow/status/astro-community/astro-rome/node.yml?branch=main\u0026amp;label=Build\u0026amp;logo=node.js\u0026amp;color=white\u0026amp;logoColor=black\u0026amp;labelColor=white\u0026amp;logoWidth=15\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/astro-community/astro-rome/node.yml?branch=main\u0026amp;label=Build\u0026amp;logo=node.js\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003c/picture\u003e\u003c/a\u003e\u003cbr\u003e\u003ca href=https://npmjs.org/astro-rome target=_blank\u003e\u003cpicture\u003e\u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/npm/v/astro-rome?label=Version\u0026amp;logo=npm\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/npm/v/astro-rome?label=Version\u0026amp;logo=npm\u0026amp;color=white\u0026amp;logoColor=black\u0026amp;labelColor=white\u0026amp;logoWidth=15\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/astro-rome?label=Version\u0026amp;logo=npm\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003c/picture\u003e\u003c/a\u003e\u003cbr\u003e\u003ca href=https://npmjs.org/astro-rome target=_blank\u003e\u003cpicture\u003e\u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/librariesio/release/npm/astro-rome?label=Dependencies\u0026amp;logo=dependabot\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/librariesio/release/npm/astro-rome?label=Dependencies\u0026amp;logo=dependabot\u0026amp;color=white\u0026amp;logoColor=black\u0026amp;labelColor=white\u0026amp;logoWidth=15\"\u003e\u003cimg src=\"https://img.shields.io/librariesio/release/npm/astro-rome?label=Dependencies\u0026amp;logo=dependabot\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003c/picture\u003e\u003c/a\u003e\u003cbr\u003e\u003ca href=https://npmjs.org/astro-rome target=_blank\u003e\u003cpicture\u003e\u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/npm/dw/astro-rome?label=Downloads\u0026amp;logo=npm\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/npm/dw/astro-rome?label=Downloads\u0026amp;logo=npm\u0026amp;color=white\u0026amp;logoColor=black\u0026amp;labelColor=white\u0026amp;logoWidth=15\"\u003e\u003cimg src=\"https://img.shields.io/npm/dw/astro-rome?label=Downloads\u0026amp;logo=npm\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003c/picture\u003e\u003c/a\u003e\u003cbr\u003e\u003cbr\u003e\u003c/td\u003e\u003ctd colspan=1 valign=top\u003e\u003cbr\u003e\u003ca href=https://github.com/astro-community/astro-rome target=_blank\u003e\u003cpicture\u003e\u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/github/stars/astro-community/astro-rome?label=stars\u0026amp;logo=github\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/github/stars/astro-community/astro-rome?label=stars\u0026amp;logo=github\u0026amp;color=white\u0026amp;logoColor=black\u0026amp;labelColor=white\u0026amp;logoWidth=15\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/astro-community/astro-rome?label=stars\u0026amp;logo=github\u0026amp;color=black\u0026amp;logoColor=white\u0026amp;labelColor=black\u0026amp;logoWidth=15\"\u003e\u003c/picture\u003e\u003c/a\u003e\u003cbr\u003e\u003ca href=https://github.com/astro-community/astro-rome target=_blank\u003e\u003cb\u003eastro-rome\u003c/b\u003e\u003c/a\u003e\u003cbr\u003e\u003cb\u003e🏛️ AstroJS Rome tools.\u003cbr\u003eFormat, lint and check your Astro website with Rome.\u003cbr\u003e\u003c/b\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\n\n# [astro-compress] 🗜️\n\nThis **[Astro integration][astro-integration]** brings compression utilities to\nyour Astro project.\n\n[CSS][csso] [HTML][html-minifier-terser] [JavaScript][terser] [Images][sharp]\n[SVG][svgo]\n\n\u003e **Note**\n\u003e\n\u003e `astro-compress` will not compress your requests, only your statically\n\u003e generated build and pre-rendered routes.\n\n\u003e **Note**\n\u003e\n\u003e Use `astro-compress` last in your integration list for the best optimizations.\n\n## Installation\n\nThere are two ways to add integrations to your project. Let's try the most\nconvenient option first!\n\n### `astro add` command\n\nAstro includes a CLI tool for adding first party integrations: `astro add`. This\ncommand will:\n\n1. (Optionally) Install all necessary dependencies and peer dependencies\n2. (Also optionally) Update your `astro.config.*` file to apply this integration\n\nTo install `astro-compress`, run the following from your project directory and\nfollow the prompts:\n\nUsing NPM:\n\n```sh\nnpx astro add astro-compress\n```\n\nUsing Yarn:\n\n```sh\nyarn astro add astro-compress\n```\n\nUsing PNPM:\n\n```sh\npnpx astro add astro-compress\n```\n\n### Install dependencies manually\n\nFirst, install the `astro-compress` integration like so:\n\n```\nnpm install -D -E astro-compress\n```\n\nThen, apply this integration to your `astro.config.*` file using the\n`integrations` property:\n\n**`astro.config.ts`**\n\n```ts\nimport Compress from \"astro-compress\";\n\nexport default { integrations: [Compress()] };\n```\n\n## Getting started\n\nThe utility will now automatically compress all your CSS, HTML, SVG, JavaScript\nand image files in the Astro `outDir` folder.\n\nThe following image file types will be compressed via [sharp]:\n\n-   avci\n-   avcs\n-   avif\n-   avifs\n-   gif\n-   heic\n-   heics\n-   heif\n-   heifs\n-   jfif\n-   jif\n-   jpe\n-   jpeg\n-   jpg\n-   apng\n-   png\n-   raw\n-   tiff\n-   webp\n\nSVG compression is supported via [svgo].\n\n#### You can override any of the default options from the configurations of:\n\n-   [csso](https://github.com/css/csso#minifysource-options)\n-   [html-minifier-terser](https://github.com/terser/html-minifier-terser#options-quick-reference)\n-   [sharp](https://sharp.pixelplumbing.com/api-output#jpeg)\n-   [svgo](https://github.com/svg/svgo#configuration)\n-   [terser](https://github.com/terser/terser#minify-options-structure)\n\nor disable them entirely:\n\n**`astro.config.ts`**\n\n```ts\nimport Compress from \"astro-compress\";\n\nexport default {\n\tintegrations: [\n\t\tCompress({\n\t\t\tcss: false,\n\t\t\thtml: false,\n\t\t\timg: false,\n\t\t\tjs: false,\n\t\t\tsvg: false,\n\t\t}),\n\t],\n};\n```\n\n#### If your path is different than the Astro `outDir` be sure to update it accordingly:\n\n**`astro.config.ts`**\n\n```ts\nimport Compress from \"astro-compress\";\n\nexport default {\n\toutDir: \"./Target\",\n\tintegrations: [\n\t\tCompress({\n\t\t\tpath: \"./Target\",\n\t\t}),\n\t],\n};\n```\n\n#### You can add multiple paths to compress by specifying an array as the `path` variable.\n\n**`astro.config.ts`**\n\n```ts\nimport Compress from \"astro-compress\";\n\nexport default {\n\tintegrations: [\n\t\tCompress({\n\t\t\tpath: [\"./Target\", \"./Build\"],\n\t\t}),\n\t],\n};\n```\n\n#### You can also provide a map of paths for different input output directories.\n\n**`astro.config.ts`**\n\n```ts\nimport Compress from \"astro-compress\";\n\nexport default {\n\tintegrations: [\n\t\tCompress({\n\t\t\tpath: new Map([[\"./input\", \"./output\"]]),\n\t\t}),\n\t],\n};\n```\n\n#### Or an array of the two.\n\n**`astro.config.ts`**\n\n```ts\nimport Compress from \"astro-compress\";\n\nexport default {\n\tintegrations: [\n\t\tCompress({\n\t\t\tpath: [\n\t\t\t\t// Compress Target\n\t\t\t\t\"./Target\",\n\t\t\t\t// Compress Target one more time into a different directory\n\t\t\t\tnew Map([[\"./Target\", \"./TargetCompress\"]]),\n\t\t\t],\n\t\t}),\n\t],\n};\n```\n\n#### You can provide a filter to exclude files in your build. A filter can be an array of regexes or a single match. You can use functions, as well to match on file names.\n\n**`astro.config.ts`**\n\n```ts\nimport Compress from \"astro-compress\";\n\nexport default {\n\tintegrations: [\n\t\tCompress({\n\t\t\texclude: [\n\t\t\t\t\"my-awesome.png\",\n\t\t\t\t(file: string) =\u003e\n\t\t\t\t\tfile === \"./Target/Images/favicon/safari-pinned-tab.svg\",\n\t\t\t],\n\t\t}),\n\t],\n};\n```\n\n#### Set `logger` to `0` if you do not want to see debug messages. Default is `2`.\n\n**`astro.config.ts`**\n\n```ts\nimport Compress from \"astro-compress\";\n\nexport default {\n\tintegrations: [\n\t\tCompress({\n\t\t\tlogger: 0,\n\t\t}),\n\t],\n};\n```\n\n[astro-compress]: https://npmjs.org/astro-compress\n[csso]: https://npmjs.org/csso\n[html-minifier-terser]: https://npmjs.org/html-minifier-terser\n[terser]: https://npmjs.org/terser\n[sharp]: https://npmjs.org/sharp\n[svgo]: https://npmjs.org/svgo\n[astro-integration]: https://docs.astro.build/en/guides/integrations-guide/\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md) for a history of changes to this integration.\n\n[![Lightrix logo](https://raw.githubusercontent.com/Lightrix/NPM/main/.github/Image/favicon.png \"Built with Lightrix/NPM\")](https://github.com/Lightrix/NPM)\n\u003csup\u003eBuilt with [`Lightrix/NPM`](https://github.com/Lightrix/NPM), powered by\n[`Lightrix/files-pipe`](https://github.com/Lightrix/files-pipe).\u003c/sup\u003e\n","funding_links":[],"categories":["🌟 Community Integrations"],"sub_categories":["Performance \u0026 Optimization"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamranahmedse%2Fastro-compress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkamranahmedse%2Fastro-compress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamranahmedse%2Fastro-compress/lists"}