{"id":13580816,"url":"https://github.com/advanced-astro/astro-compress","last_synced_at":"2025-04-06T06:32:04.127Z","repository":{"id":56798696,"uuid":"525540949","full_name":"advanced-astro/astro-compress","owner":"advanced-astro","description":"🗜️ AstroJS compression utilities. Compress CSS, HTML, JavaScript and more.","archived":false,"fork":true,"pushed_at":"2025-03-20T00:12:14.000Z","size":51334,"stargazers_count":3,"open_issues_count":12,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-20T01:23:26.146Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"PlayForm/Compress","license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/advanced-astro.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-16T21:00:11.000Z","updated_at":"2025-03-20T00:11:39.000Z","dependencies_parsed_at":"2023-02-18T04:30:53.228Z","dependency_job_id":null,"html_url":"https://github.com/advanced-astro/astro-compress","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/advanced-astro%2Fastro-compress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/advanced-astro%2Fastro-compress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/advanced-astro%2Fastro-compress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/advanced-astro%2Fastro-compress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/advanced-astro","download_url":"https://codeload.github.com/advanced-astro/astro-compress/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445649,"owners_count":20939952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-08-01T15:01:55.314Z","updated_at":"2025-04-06T06:32:04.120Z","avatar_url":"https://github.com/advanced-astro.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003ctable\u003e\u003ctr\u003e \u003ctd colspan=\"1\"\u003e \u003ch3 align=\"center\"\u003e \u003cpicture\u003e \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://PlayForm.LTD/Dark/Image/GitHub/Astro.svg\"\u003e \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://PlayForm.LTD/Image/GitHub/Astro.svg\"\u003e \u003cimg width=\"28\" alt=\"Astro\" src=\"https://PlayForm.LTD/Image/GitHub/Astro.svg\"\u003e \u003c/picture\u003e  \u003c/h3\u003e \u003c/td\u003e \u003ctd colspan=\"3\" valign=\"top\"\u003e \u003ch3 align=\"center\"\u003e Related \u003c/h3\u003e \u003c/td\u003e \u003c/tr\u003e\u003ctr\u003e\u003ctd valign=\"top\" colspan=\"1\"\u003e\u003ca href=\"HTTPS://GitHub.Com/PlayForm/Inline/actions/workflows/Node.yml\" target=\"_blank\"\u003e \u003cpicture\u003e \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/github/actions/workflow/status/PlayForm/Inline/Node.yml?branch=main\u0026label=Build\u0026logo=node.js\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\"\u003e \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/github/actions/workflow/status/PlayForm/Inline/Node.yml?branch=main\u0026label=Build\u0026logo=node.js\u0026color=white\u0026labelColor=white\u0026logoColor=black\u0026logoWidth=0\"\u003e \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/PlayForm/Inline/Node.yml?branch=main\u0026label=Build\u0026logo=node.js\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\" alt=\"Build\" title=\"Build\"\u003e \u003c/picture\u003e \u003c/a\u003e\u003cbr\u003e\u003ca href=\"HTTPS://NPMJS.Org/@playform/inline?activeTab=dependencies\" target=\"_blank\"\u003e \u003cpicture\u003e \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/librariesio/release/npm/@playform/inline?logo=dependabot\u0026label=\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\"\u003e \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/librariesio/release/npm/@playform/inline?logo=dependabot\u0026label=\u0026color=white\u0026labelColor=white\u0026logoColor=black\u0026logoWidth=0\"\u003e \u003cimg src=\"https://img.shields.io/librariesio/release/npm/@playform/inline?logo=dependabot\u0026label=\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\" alt=\"Dependency\" title=\"Dependency\"\u003e \u003c/picture\u003e \u003c/a\u003e\u003cbr\u003e\u003ca href=\"HTTPS://NPMJS.Org/@playform/inline\" target=\"_blank\"\u003e \u003cpicture\u003e \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/npm/v/@playform/inline?label=Version\u0026logo=npm\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\"\u003e \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/npm/v/@playform/inline?label=Version\u0026logo=npm\u0026color=white\u0026labelColor=white\u0026logoColor=black\u0026logoWidth=0\"\u003e \u003cimg src=\"https://img.shields.io/npm/v/@playform/inline?label=Version\u0026logo=npm\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\" alt=\"Version\" title=\"Version\"\u003e \u003c/picture\u003e \u003c/a\u003e\u003cbr\u003e\u003c/td\u003e\u003ctd valign=\"top\" colspan=\"1\"\u003e\u003ca href=\"HTTPS://GitHub.Com/PlayForm/Inline\" target=\"_blank\"\u003e\u003cpicture\u003e\u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/github/stars/PlayForm/Inline?style=flat\u0026label=Star\u0026logo=github\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\"\u003e\u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/github/stars/PlayForm/Inline?style=flat\u0026label=Star\u0026logo=github\u0026color=white\u0026labelColor=white\u0026logoColor=black\u0026logoWidth=0\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/PlayForm/Inline?style=flat\u0026label=Star\u0026logo=github\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\" alt=\"Star\"\u003e\u003c/picture\u003e\u003c/a\u003e\u003cbr\u003e\u003ca href=\"HTTPS://NPMJS.Org/@playform/inline\" target=\"_blank\"\u003e \u003cpicture\u003e \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/npm/dt/@playform/inline?label=Download\u0026logo=npm\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\"\u003e \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/npm/dt/@playform/inline?label=Download\u0026logo=npm\u0026color=white\u0026labelColor=white\u0026logoColor=black\u0026logoWidth=0\"\u003e \u003cimg src=\"https://img.shields.io/npm/dt/@playform/inline?label=Download\u0026logo=npm\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\" alt=\"Download\" title=\"Download\"\u003e \u003c/picture\u003e \u003c/a\u003e\u003cbr\u003e\u003ca href=\"HTTPS://GitHub.Com/PlayForm/Inline\" target=\"_blank\"\u003e\u003cb\u003eInline 🦔\u003c/b\u003e\u003c/a\u003e\u003c/td\u003e\u003ctd valign=\"top\" colspan=\"1\"\u003e\u003ca href=\"HTTPS://GitHub.Com/PlayForm/Format/actions/workflows/Node.yml\" target=\"_blank\"\u003e \u003cpicture\u003e \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/github/actions/workflow/status/PlayForm/Format/Node.yml?branch=main\u0026label=Build\u0026logo=node.js\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\"\u003e \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/github/actions/workflow/status/PlayForm/Format/Node.yml?branch=main\u0026label=Build\u0026logo=node.js\u0026color=white\u0026labelColor=white\u0026logoColor=black\u0026logoWidth=0\"\u003e \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/PlayForm/Format/Node.yml?branch=main\u0026label=Build\u0026logo=node.js\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\" alt=\"Build\" title=\"Build\"\u003e \u003c/picture\u003e \u003c/a\u003e\u003cbr\u003e\u003ca href=\"HTTPS://NPMJS.Org/@playform/format?activeTab=dependencies\" target=\"_blank\"\u003e \u003cpicture\u003e \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/librariesio/release/npm/@playform/format?logo=dependabot\u0026label=\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\"\u003e \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/librariesio/release/npm/@playform/format?logo=dependabot\u0026label=\u0026color=white\u0026labelColor=white\u0026logoColor=black\u0026logoWidth=0\"\u003e \u003cimg src=\"https://img.shields.io/librariesio/release/npm/@playform/format?logo=dependabot\u0026label=\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\" alt=\"Dependency\" title=\"Dependency\"\u003e \u003c/picture\u003e \u003c/a\u003e\u003cbr\u003e\u003ca href=\"HTTPS://NPMJS.Org/@playform/format\" target=\"_blank\"\u003e \u003cpicture\u003e \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/npm/v/@playform/format?label=Version\u0026logo=npm\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\"\u003e \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/npm/v/@playform/format?label=Version\u0026logo=npm\u0026color=white\u0026labelColor=white\u0026logoColor=black\u0026logoWidth=0\"\u003e \u003cimg src=\"https://img.shields.io/npm/v/@playform/format?label=Version\u0026logo=npm\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\" alt=\"Version\" title=\"Version\"\u003e \u003c/picture\u003e \u003c/a\u003e\u003cbr\u003e\u003c/td\u003e\u003ctd valign=\"top\" colspan=\"1\"\u003e\u003ca href=\"HTTPS://GitHub.Com/PlayForm/Format\" target=\"_blank\"\u003e\u003cpicture\u003e\u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/github/stars/PlayForm/Format?style=flat\u0026label=Star\u0026logo=github\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\"\u003e\u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/github/stars/PlayForm/Format?style=flat\u0026label=Star\u0026logo=github\u0026color=white\u0026labelColor=white\u0026logoColor=black\u0026logoWidth=0\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/PlayForm/Format?style=flat\u0026label=Star\u0026logo=github\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\" alt=\"Star\"\u003e\u003c/picture\u003e\u003c/a\u003e\u003cbr\u003e\u003ca href=\"HTTPS://NPMJS.Org/@playform/format\" target=\"_blank\"\u003e \u003cpicture\u003e \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://img.shields.io/npm/dt/@playform/format?label=Download\u0026logo=npm\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\"\u003e \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://img.shields.io/npm/dt/@playform/format?label=Download\u0026logo=npm\u0026color=white\u0026labelColor=white\u0026logoColor=black\u0026logoWidth=0\"\u003e \u003cimg src=\"https://img.shields.io/npm/dt/@playform/format?label=Download\u0026logo=npm\u0026color=black\u0026labelColor=black\u0026logoColor=white\u0026logoWidth=0\" alt=\"Download\" title=\"Download\"\u003e \u003c/picture\u003e \u003c/a\u003e\u003cbr\u003e\u003ca href=\"HTTPS://GitHub.Com/PlayForm/Format\" target=\"_blank\"\u003e\u003cb\u003eFormat 🗻\u003c/b\u003e\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\n# [Compress] 🗜️\n\nThis **[`Astro integration`][astro-integration]** brings compression utilities\nto your Astro project.\n\n[`CSS (csso)`][csso] 🎁\n\n[`CSS (lightningcss)`][lightningcss] 🎁\n\n[`HTML (html-minifier-terser)`][html-minifier-terser] 🎁\n\n[`Image (sharp)`][sharp] 🎁\n\n[`JavaScript (terser)`][terser] 🎁\n\n[`SVG (svgo)`][svgo] 🎁\n\n\u003e **Note**\n\u003e\n\u003e `Compress` will not compress your requests, only your statically generated\n\u003e build and pre-rendered routes.\n\n\u003e [!IMPORTANT]\n\u003e\n\u003e Use `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 `Compress`, run the following from your project directory and follow\nthe prompts:\n\nUsing NPM:\n\n```sh\nnpx astro add @playform/compress\n```\n\nUsing Yarn:\n\n```sh\nyarn astro add @playform/compress\n```\n\nUsing PNPM:\n\n```sh\npnpx astro add @playform/compress\n```\n\n### Install dependencies manually\n\nFirst, install the `Compress` integration like so:\n\n```sh\nnpm install -D -E @playform/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\nexport default {\n\tintegrations: [(await import(\"@playform/compress\")).default()],\n};\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`][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, as well via [`svgo`][svgo].\n\n### Default Compression\n\nYou can override any of the default options from the configurations of:\n\n- [`csso`](HTTPS://GitHub.Com/css/csso#minifysource-options)\n- [`lightningcss`](HTTPS://GitHub.Com/parcel-bundler/lightningcss/blob/master/node/index.d.ts#L8)\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\n**`astro.config.ts`**\n\n```ts\nexport default {\n\tintegrations: [\n\t\t(await import(\"@playform/compress\")).default({\n\t\t\tCSS: false,\n\t\t\tHTML: {\n\t\t\t\t\"html-minifier-terser\": {\n\t\t\t\t\tremoveAttributeQuotes: false,\n\t\t\t\t},\n\t\t\t},\n\t\t\tImage: false,\n\t\t\tJavaScript: false,\n\t\t\tSVG: false,\n\t\t}),\n\t],\n};\n```\n\nor disable them entirely:\n\n**`astro.config.ts`**\n\n```ts\nexport default {\n\tintegrations: [\n\t\t(await import(\"@playform/compress\")).default({\n\t\t\tCSS: false,\n\t\t\tHTML: false,\n\t\t\tImage: false,\n\t\t\tJavaScript: false,\n\t\t\tSVG: false,\n\t\t}),\n\t],\n};\n```\n\nYou can see the full option map here:\n[`Source/Interface/Option.ts`](HTTPS://GitHub.Com/PlayForm/Compress/blob/main/Source/Interface/Option.ts)\n\n### Output\n\nBy default `Compress` compresses the `outDir` `Astro` directory, if you'd like\nit to compress a different directory you would have to add it to the `Compress`\n`Path` option, as well:\n\n```ts\nexport default {\n\tintegrations: [\n\t\t(await import(\"@playform/compress\")).default({\n\t\t\tPath: [\"./dist\", \"./Compress\"],\n\t\t}),\n\t],\n};\n```\n\n### Add Multiple Paths\n\nYou can add multiple paths to compress by specifying an array as the `Path`\nvariable.\n\n**`astro.config.ts`**\n\n```ts\nexport default {\n\tintegrations: [\n\t\t(await import(\"@playform/compress\")).default({\n\t\t\tPath: [\"./Target\", \"./Build\"],\n\t\t}),\n\t],\n};\n```\n\n### Input-Output Mapping\n\nYou can also provide a map of paths for different input output directories.\n\n**`astro.config.ts`**\n\n```ts\nexport default {\n\tintegrations: [\n\t\t(await import(\"@playform/compress\")).default({\n\t\t\tPath: new Map([[\"./Source\", \"./Target\"]]),\n\t\t}),\n\t],\n};\n```\n\nOr an array of the two:\n\n**`astro.config.ts`**\n\n```ts\nexport default {\n\tintegrations: [\n\t\t(await import(\"@playform/compress\")).default({\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### File Filtering\n\nYou can filter files to exclude specific ones from compression. A filter can be\nan array of regular expressions or a single match. You can also use functions to\nmatch on file names:\n\n**`astro.config.ts`**\n\n```ts\nexport default {\n\tintegrations: [\n\t\t(await import(\"@playform/compress\")).default({\n\t\t\tExclude: [\n\t\t\t\t\"File.png\",\n\t\t\t\t(File: string) =\u003e\n\t\t\t\t\tFile === \"./Target/Favicon/Image/safari-pinned-tab.svg\",\n\t\t\t],\n\t\t}),\n\t],\n};\n```\n\n### Controlling Logging\n\nYou can control the logging level by setting the `Logger` parameter. The default\nvalue is `2`, but you can set it to `0` if you don't want to see debug messages:\n\n**`astro.config.ts`**\n\n```ts\nexport default {\n\tintegrations: [\n\t\t(await import(\"@playform/compress\")).default({\n\t\t\tLogger: 0,\n\t\t}),\n\t],\n};\n```\n\n[Compress]: HTTPS://NPMJS.Org/@playform/compress\n[csso]: HTTPS://NPMJS.Org/csso\n[lightningcss]: HTTPS://NPMJS.Org/lightningcss\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadvanced-astro%2Fastro-compress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadvanced-astro%2Fastro-compress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadvanced-astro%2Fastro-compress/lists"}