{"id":15495821,"url":"https://github.com/kejunmao/unplugin-compression","last_synced_at":"2025-07-28T12:37:40.059Z","repository":{"id":61839082,"uuid":"553530936","full_name":"KeJunMao/unplugin-compression","owner":"KeJunMao","description":"Compress dist to zip, tar, taz.","archived":false,"fork":false,"pushed_at":"2023-12-05T23:42:05.000Z","size":557,"stargazers_count":16,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-22T21:03:05.831Z","etag":null,"topics":["unplugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KeJunMao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-10-18T11:05:08.000Z","updated_at":"2025-01-04T04:11:00.000Z","dependencies_parsed_at":"2023-01-21T02:03:29.486Z","dependency_job_id":"a2f12787-299f-4b53-8c2d-55bf43ea03c0","html_url":"https://github.com/KeJunMao/unplugin-compression","commit_stats":{"total_commits":17,"total_committers":1,"mean_commits":17.0,"dds":0.0,"last_synced_commit":"e2d5970d9e3df3cefdcafc71a8207205cb22b88e"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeJunMao%2Funplugin-compression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeJunMao%2Funplugin-compression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeJunMao%2Funplugin-compression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeJunMao%2Funplugin-compression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KeJunMao","download_url":"https://codeload.github.com/KeJunMao/unplugin-compression/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250324690,"owners_count":21411945,"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":["unplugin"],"created_at":"2024-10-02T08:19:46.602Z","updated_at":"2025-04-22T21:04:54.426Z","avatar_url":"https://github.com/KeJunMao.png","language":"TypeScript","readme":"\u003cimg src=\"./assets/logo.svg\" alt=\"logo of vite-plugin-patch-env repository\" width=\"100\" height=\"100\" align=\"right\" /\u003e\n\n# unplugin-compression\n\n\u003e Compress dist to `zip`, `tar`, `taz`. Powered by [unplugin](https://github.com/unjs/unplugin).\n\nEnglish | [简体中文](./README.zh-CN.md)\n\n## Installation\n\n```bash\npnpm i -D unplugin-compression\n```\n\n## Usage\n\n\u003cdetails\u003e\n\u003csummary\u003eVite\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// vite.config.ts\nimport Compression from \"unplugin-compression/vite\";\n\nexport default defineConfig({\n  plugins: [\n    Compression({\n      /* options */\n    }),\n  ],\n});\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eRollup\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// rollup.config.js\nimport Compression from \"unplugin-compression/rollup\";\n\nexport default {\n  plugins: [\n    Compression({\n      /* options */\n    }),\n  ],\n};\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eWebpack\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// webpack.config.js\nmodule.exports = {\n  /* ... */\n  plugins: [\n    require(\"unplugin-compression/webpack\")({\n      /* options */\n    }),\n  ],\n};\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eVue CLI\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// vue.config.js\nmodule.exports = {\n  configureWebpack: {\n    plugins: [\n      require(\"unplugin-compression/webpack\")({\n        /* options */\n      }),\n    ],\n  },\n};\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eesbuild\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// esbuild.config.js\nimport { build } from \"esbuild\";\n\nbuild({\n  /* ... */\n  plugins: [\n    require(\"unplugin-compression/esbuild\")({\n      /* options */\n    }),\n  ],\n});\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n## Configuration\n\n```ts\nCompression({\n  // you can use `zip`, `tar`, `taz`\n  adapter: \"zip\",\n  // relative paths to the directory to compress\n  source: \"dist\",\n  // relative paths to the directory to output\n  outDir: \"./\",\n  // compressed file name\n  formatter: \"{{name}}.{{ext}}\",\n});\n```\n\n### `adapter`\n\nGlobal adapter. When the source does not set the adapter, the global adapter is used.\n\nsee [compressing](https://github.com/node-modules/compressing)\n\n### `source`\n\nThe compress source, which can be set as `string` or `Source` or `Source[]`\n\nIf you use `Source` and set `adapter` or `outDir` or `formatter` options, it's cover global options.\n\n```ts\nCompression({\n  source: [\n    {\n      // zip adapter, dist.zip\n      source: \"dist\",\n    },\n    {\n      // tar adapter, output.tar\n      source: \"output\",\n      adapter: \"tar\",\n    },\n  ],\n});\n```\n\n### `outDir`\n\nThe compressed file output dir.\n\n### `formatter`\n\nThe compressed filename formatter. default value is `{{name}}.{{ext}}`.\n\n```ts\ninterface template extends Omit\u003cSource, \"formatter\"\u003e {\n  name: string;\n  ext: string;\n}\n```\n\nyou can also set a handler\n\n```ts\nCompression({\n  formatter(source) {\n    return `Hello.${source.adapter}`;\n  },\n});\n```\n\n### `compressingOptions`\n\nthe compressing package opts. see [compressing](https://github.com/node-modules/compressing)\n\n```ts\nCompression({\n  compressingOptions: {\n    ignoreBase: true,\n  },\n});\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkejunmao%2Funplugin-compression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkejunmao%2Funplugin-compression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkejunmao%2Funplugin-compression/lists"}