{"id":21240254,"url":"https://github.com/retyui/postcss-finding-dead-css","last_synced_at":"2026-04-29T06:37:32.379Z","repository":{"id":57328005,"uuid":"118934715","full_name":"retyui/postcss-finding-dead-css","owner":"retyui","description":"Idea: https://csswizardry.com/2018/01/finding-dead-css/","archived":false,"fork":false,"pushed_at":"2018-05-10T16:57:55.000Z","size":117,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-24T16:19:01.451Z","etag":null,"topics":["postcss","postcss-plugin"],"latest_commit_sha":null,"homepage":null,"language":"CSS","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/retyui.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}},"created_at":"2018-01-25T16:00:23.000Z","updated_at":"2018-02-13T08:39:53.000Z","dependencies_parsed_at":"2022-09-18T10:20:20.803Z","dependency_job_id":null,"html_url":"https://github.com/retyui/postcss-finding-dead-css","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/retyui/postcss-finding-dead-css","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retyui%2Fpostcss-finding-dead-css","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retyui%2Fpostcss-finding-dead-css/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retyui%2Fpostcss-finding-dead-css/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retyui%2Fpostcss-finding-dead-css/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/retyui","download_url":"https://codeload.github.com/retyui/postcss-finding-dead-css/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retyui%2Fpostcss-finding-dead-css/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262783703,"owners_count":23363599,"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":["postcss","postcss-plugin"],"created_at":"2024-11-21T00:50:15.492Z","updated_at":"2026-04-29T06:37:27.341Z","avatar_url":"https://github.com/retyui.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# postcss-finding-dead-css\n\n![postcss-finding-dead-css](https://retyui.github.io/postcss-finding-dead-code/logo.svg)\n\n\n[![npm](https://img.shields.io/npm/v/postcss-finding-dead-css.svg)](https://www.npmjs.com/package/postcss-finding-dead-css)\n[![David](https://img.shields.io/david/retyui/postcss-finding-dead-css.svg)](https://david-dm.org/retyui/postcss-finding-dead-css)\n\nPostCSS plugin that help identifying the dead code. [Idea](https://csswizardry.com/2018/01/finding-dead-css/). Only my plugin uses only the css border-image property.\n\n\n## Install\n\n```bash\nyarn add -D postcss-finding-dead-css\n# or npm install --save-dev postcss-finding-dead-css\n```\n\n## Input:\n\n```css\nbody {\n  margin: 0;\n}\n\n.alredy-use-border-image {\n  border-image: linear-gradient(red, yellow) 10;\n}\n```\n\n## Output:\n\n```css\nbody {\n  margin: 0;\n  border-image-source: url('/cssdead?data=%7B%22selector%22:%22body%22,%22startLine%22:1,%22startColumn%22:1%7D\u0026file=/path/to/file.css');\n}\n\n.alredy-use-border-image {\n  border-image: linear-gradient(red, yellow) 10;\n}\n```\n\n## Usage ([examples](https://github.com/retyui/postcss-finding-dead-css/tree/master/example/))\n\n```js\n// Node.js 8.x\nconst { readFileSync, writeFileSync } = require(\"fs\");\nconst { resolve } = require(\"path\");\nconst postcss = require(\"postcss\");\nconst postcssDeadCss = require(\"postcss-finding-dead-css\");\nconst [from, to] = [\"./input.css\", \"./output.css\"].map(f =\u003e\n  resolve(__dirname, f)\n);\nconst CSS = readFileSync(from);\nconst PLUGINS = [\n  postcssDeadCss({\n    // deadApiUrl: \"http://my-analytic.server.com/cssdead\", // default '/cssdead'\n    // url({selector, startLine, startColumn, file}) { // custom url\n    //   return encodeURI(\n    //     `${this.deadApiUrl}?data=${JSON.stringify({\n    //       selector,\n    //       startLine,\n    //       startColumn\n    //     })}\u0026file=${file}`\n    //   );\n    // }\n  })\n];\n\n(async () =\u003e {\n  try {\n    const { css, messages } = await postcss(PLUGINS).process(CSS, { from, to });\n    messages\n      .filter(({ type }) =\u003e type === \"warning\")\n      .map(msg =\u003e console.log(msg.toString()));\n    console.log(css);\n    writeFileSync(to, css);\n  } catch (e) {\n    console.error(e);\n  }\n})();\n```\n\n## Options\n### `deadApiUrl` , type: `String`, required: `false`\ndefault: `'/cssdead'`\n\nUrl to back-end api, I send two parametrs `type` and `file`\n\n`type` - has json `{ selector, startLine, startColumn }`\n\n`file` - path to source css file\n\n### `url` , type: `Function`, required: `false`\n\nThis function help you customize url generation\n\n\n## [Middleware](https://github.com/retyui/postcss-finding-dead-css/tree/master/src/middleware.js)\n\n### Usage ([example](https://github.com/retyui/postcss-finding-dead-css/tree/master/example/browser-sync/server.js))\n\n```js\n// Node.js 8.x\n// example get middlewares:\nconst {getMiddleware} = require('postcss-finding-dead-css');\nconst {middlewareCheckDead, middlewareStat} = getMiddleware(options);\n\n// Express.js\nconst app = express();\n\napp.get(options.deadApiUrl, middlewareCheckDead);\n```\n\n### Options\n\n```js\n{\n  deadApiUrl: '/custom/path',      // defualt: '/cssdead'\n  statApiUrl: '/custom/path/stat'  // defualt: '/getStat'\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretyui%2Fpostcss-finding-dead-css","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fretyui%2Fpostcss-finding-dead-css","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretyui%2Fpostcss-finding-dead-css/lists"}