{"id":13941906,"url":"https://github.com/patrickhulce/nukecss","last_synced_at":"2025-03-19T03:30:24.595Z","repository":{"id":66227423,"uuid":"82422719","full_name":"patrickhulce/nukecss","owner":"patrickhulce","description":"Eliminates unused CSS rules. Built for single-page apps.","archived":false,"fork":false,"pushed_at":"2019-04-10T23:03:15.000Z","size":100,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-12T10:42:18.940Z","etag":null,"topics":["css","nukecss","purifycss","remove","uncss","unused"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/patrickhulce.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":"2017-02-18T23:31:41.000Z","updated_at":"2020-05-29T17:27:03.000Z","dependencies_parsed_at":"2023-02-25T05:00:17.457Z","dependency_job_id":null,"html_url":"https://github.com/patrickhulce/nukecss","commit_stats":{"total_commits":48,"total_committers":1,"mean_commits":48.0,"dds":0.0,"last_synced_commit":"d9eb8dd7a29ddc0822b08bc939c805cb06ab6a32"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickhulce%2Fnukecss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickhulce%2Fnukecss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickhulce%2Fnukecss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickhulce%2Fnukecss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patrickhulce","download_url":"https://codeload.github.com/patrickhulce/nukecss/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244350560,"owners_count":20439281,"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":["css","nukecss","purifycss","remove","uncss","unused"],"created_at":"2024-08-08T02:01:35.258Z","updated_at":"2025-03-19T03:30:24.258Z","avatar_url":"https://github.com/patrickhulce.png","language":"JavaScript","readme":"# nukecss\n[![NPM Package](https://badge.fury.io/js/nukecss.svg)](https://www.npmjs.com/package/nukecss)\n[![Build Status](https://travis-ci.org/patrickhulce/nukecss.svg?branch=master)](https://travis-ci.org/patrickhulce/nukecss)\n[![Coverage Status](https://coveralls.io/repos/github/patrickhulce/nukecss/badge.svg?branch=master)](https://coveralls.io/github/patrickhulce/nukecss?branch=master)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![Dependencies](https://david-dm.org/patrickhulce/nukecss.svg)](https://david-dm.org/patrickhulce/nukecss)\n\nEliminates unused CSS rules. Built from the ground up for single-page apps. Inspired by [purifycss](https://github.com/purifycss/purifycss) and [uncss](https://github.com/giakki/uncss).\n\n## How It Works\n* Parses the CSS with [postcss](https://github.com/postcss/postcss) and [gonzales-pe](https://github.com/tonyganch/gonzales-pe) and walks the AST to find the IDs, classes, and DOM types used in selectors.\n* Parses HTML and JavaScript sources to find rule usage in strings and attributes, falling back to simple RegExp search when parsing fails.\n* Removes rules whose selectors cannot be found in the source set.\n\n## Usage\n`npm install --save nukecss`\n\n#### nuke.js\n```js\nconst fs = require('fs')\nconst nukecss = require('nukecss')\nconst css = fs.readFileSync('myfile.css')\n\nnukecss('./**/*.@(js|html)', css)\n// .js-class { color: white; }\n// .other-class { color: white; }\n// .still-works { color: white; }\n// #primary { color: white; }\n```\n\n#### myfile.js\n```js\nconst jsignored = \"js-class other-class\"\nconst woah = [\"still\", \"works\"].join(\"-\")\n```\n\n#### myfile.css\n```css\n.jsignored { color: white; }\n.html-ignored { color: white; }\n.js-class { color: white; }\n.other-class { color: white; }\n.still-works { color: white; }\n#primary { color: white; }\n#primary \u003e .unused { color: white; }\n.also-unused { color: white; }\n```\n\n#### myfile.html\n```html\n\u003chtml\u003e\n\u003cbody\u003e\n  \u003cdiv id=\"primary\" class=\"html-class\"\u003ehtml-ignored\u003c/div\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrickhulce%2Fnukecss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatrickhulce%2Fnukecss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrickhulce%2Fnukecss/lists"}