{"id":13361832,"url":"https://github.com/PlayForm/Compress","last_synced_at":"2025-03-12T13:31:41.234Z","repository":{"id":39671400,"uuid":"489843291","full_name":"PlayForm/Compress","owner":"PlayForm","description":"Compress 🗜️","archived":false,"fork":false,"pushed_at":"2025-03-07T01:26:55.000Z","size":51494,"stargazers_count":540,"open_issues_count":9,"forks_count":12,"subscribers_count":3,"default_branch":"Current","last_synced_at":"2025-03-07T02:27:52.753Z","etag":null,"topics":["astro","astro-component","astro-compress","astro-integration","compress","compression","css","csso","html","html-minifier-terser","image","javascript","minify","performance","playform","sharp","svg","terser","withastro"],"latest_commit_sha":null,"homepage":"https://playform.github.io/Compress/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PlayForm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"https://Stripe.PlayForm.LTD/b/3csdQZfzn2LDaBOcMN","open_collective":"playform-cloud-collective"}},"created_at":"2022-05-08T04:16:33.000Z","updated_at":"2025-03-07T01:26:59.000Z","dependencies_parsed_at":"2023-08-14T03:25:27.144Z","dependency_job_id":"bad4b324-1a20-489d-a6b0-267206fc8adb","html_url":"https://github.com/PlayForm/Compress","commit_stats":{"total_commits":3353,"total_committers":10,"mean_commits":335.3,"dds":"0.16492693110647183","last_synced_commit":"a366652945ea232b3e3394dfbb887e5497466e42"},"previous_names":["astro-community/astrocompress","astro-community/astro-compress","playform/astrocompress","playform/compressastro","playform/compress"],"tags_count":155,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlayForm%2FCompress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlayForm%2FCompress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlayForm%2FCompress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlayForm%2FCompress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PlayForm","download_url":"https://codeload.github.com/PlayForm/Compress/tar.gz/refs/heads/Current","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243226232,"owners_count":20257047,"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":["astro","astro-component","astro-compress","astro-integration","compress","compression","css","csso","html","html-minifier-terser","image","javascript","minify","performance","playform","sharp","svg","terser","withastro"],"created_at":"2024-07-29T22:01:32.672Z","updated_at":"2025-03-12T13:31:41.228Z","avatar_url":"https://github.com/PlayForm.png","language":"TypeScript","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","funding_links":["https://Stripe.PlayForm.LTD/b/3csdQZfzn2LDaBOcMN","https://opencollective.com/playform-cloud-collective"],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPlayForm%2FCompress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPlayForm%2FCompress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPlayForm%2FCompress/lists"}