{"id":19071915,"url":"https://github.com/cyansalt/vite-plugin-unused-code","last_synced_at":"2025-04-28T16:02:35.969Z","repository":{"id":172755351,"uuid":"649566272","full_name":"CyanSalt/vite-plugin-unused-code","owner":"CyanSalt","description":"Vite/Rollup plugin to detect unused files and unused exports in used files","archived":false,"fork":false,"pushed_at":"2025-04-03T08:41:30.000Z","size":562,"stargazers_count":10,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-18T18:32:21.880Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CyanSalt.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-06-05T06:51:54.000Z","updated_at":"2025-04-03T08:41:34.000Z","dependencies_parsed_at":"2025-04-18T06:46:41.555Z","dependency_job_id":null,"html_url":"https://github.com/CyanSalt/vite-plugin-unused-code","commit_stats":null,"previous_names":["cyansalt/vite-plugin-unused-code"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyanSalt%2Fvite-plugin-unused-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyanSalt%2Fvite-plugin-unused-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyanSalt%2Fvite-plugin-unused-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyanSalt%2Fvite-plugin-unused-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CyanSalt","download_url":"https://codeload.github.com/CyanSalt/vite-plugin-unused-code/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251342720,"owners_count":21574244,"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-11-09T01:32:35.416Z","updated_at":"2025-04-28T16:02:35.132Z","avatar_url":"https://github.com/CyanSalt.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vite-plugin-unused-code\n\n[![npm](https://img.shields.io/npm/v/vite-plugin-unused-code.svg)](https://www.npmjs.com/package/vite-plugin-unused-code)\n\nVite/Rollup plugin to detect unused files and unused exports in used files.\n\nThis package is a ported version of [`webpack-deadcode-plugin`](https://github.com/MQuy/webpack-deadcode-plugin).\n\n\u003e [!IMPORTANT]\n\u003e **This plugin cannot check for dependencies of non-JavaScript files or exports (for example: CSS, or types from TypeScript files), which may be misreported as unused, even if they actually appear in the compiled bundles. Please be careful!**\n\n## Installation\n\n```shell\nnpm install --save-dev vite-plugin-unused-code\n```\n\n## Usage\n\n```js\n// vite.config.js\nimport unusedCode from 'vite-plugin-unused-code'\n\nexport default {\n  plugins: [\n    unusedCode({\n      patterns: ['src/**/*.*'],\n    }),\n  ],\n}\n```\n\n## Options\n\n### `context`\n\n- **Type:** `string`\n- **Default:** `root` option of Vite, `process.cwd()` as a fallback\n\n  Current working directory where `patterns` and `exclude` are located.\n\n### `patterns`\n\n- **Type:** `string[]`\n- **Default:** `['**/*.*']`\n\n  The array of [`micromatch`](https://github.com/micromatch/micromatch) patterns to look for unused files and unused export in used files.\n\n### `exclude`\n\n- **Type:** `string[]`\n- **Default:** `[]`\n\n  *Deprecated*. The array of patterns to not look at. `{ exclude: ['foo'] }` is actually equivalent to `{ patterns: ['!foo'] }`.\n\n  This option is reserved only for compatibility with `webpack-deadcode-plugin`.\n\n### `detectUnusedFiles`\n\n- **Type:** `boolean`\n- **Default:** `true`\n\n  Whether to run unused files detection or not.\n\n### `detectUnusedExport`\n\n- **Type:** `boolean`\n- **Default:** `true`\n\n  Whether to run unused export detection in used files or not.\n\n### `log`\n\n- **Type:** `'all' | 'used' | 'none'`\n- **Default:** `none` if `logLevel` option of Vite is `'silent'`, `'unused'` if `logLevel` option of Vite is `'error'` or `'warn'`, `'all'` otherwise\n\n  Adjust console output verbosity.\n\n  - `'all'`: Show all messages.\n  - `'used'`: Only show messages when there are either unused files or unused export.\n  - `'none'`: Won't show unused files or unused export messages in the console. It can keep terminal clean when set `exportJSON` to `true`.\n\n### `exportJSON`\n\n- **Type:** `boolean | string`\n- **Default:** `false`\n\n  Whether to export data in JSON format. A `unused-code.json` file will be created in the current directory is specified as `true`. You can also specify a directory to create in it instead.\n\n### `failOnHint`\n\n- **Type:** `boolean`\n- **Default:** `false`\n\n  Whether to interrupt the compilation when unused files or exports detected.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyansalt%2Fvite-plugin-unused-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyansalt%2Fvite-plugin-unused-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyansalt%2Fvite-plugin-unused-code/lists"}