Skip to content

Commit aed5cc3

Browse files
committed
docs: update readme optics
1 parent 5af8965 commit aed5cc3

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

README.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
66
[![Dependencies](https://david-dm.org/patrickhulce/nukecss.svg)](https://david-dm.org/patrickhulce/nukecss)
77

8-
Eliminates unused CSS rules. Built for single-page apps from the ground up. Inspired by [purifycss](https://github.com/purifycss/purifycss) and [uncss](https://github.com/giakki/uncss).
8+
Eliminates 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).
99

1010
## How It Works
1111
* Parses the CSS with [gonzales-pe](https://github.com/tonyganch/gonzales-pe) and walks the AST to find the IDs, classes, and DOM types used in selectors.
@@ -15,13 +15,14 @@ Eliminates unused CSS rules. Built for single-page apps from the ground up. Insp
1515
## Usage
1616
`npm install --save nukecss`
1717

18+
#### myfile.js
1819
```js
19-
const nukecss = require('nukecss')
20+
const jsignored = "js-class other-class"
21+
const woah = ["still", "works"].join("-")
22+
```
2023

21-
const javascript = 'const jsignored = "js-class other-class"'
22-
const javascript2 = 'const woah = ["still", "works"].join("-")'
23-
const html = '<div id="primary" class="html-class">html-ignored</div>'
24-
const css = `
24+
#### myfile.css
25+
```css
2526
.jsignored { color: white; }
2627
.html-ignored { color: white; }
2728
.js-class { color: white; }
@@ -30,16 +31,23 @@ const css = `
3031
#primary { color: white; }
3132
#primary > .unused { color: white; }
3233
.also-unused { color: white; }
33-
`
34+
```
35+
36+
#### nuke.js
37+
```js
38+
const fs = require('fs')
39+
const nukecss = require('nukecss')
3440

35-
const nuked = nukecss([
41+
const javascript = fs.readFileSync('myfile.js')
42+
const css = fs.readFileSync('myfile.css')
43+
const html = '<div id="primary" class="html-class">html-ignored</div>'
44+
45+
nukecss([
3646
{content: javascript, type: 'js'},
37-
{content: javascript2, type: 'js'},
3847
{content: html, type: 'html'},
3948
], css)
40-
> console.log(nuked)
41-
.js-class { color: white; }
42-
.other-class { color: white; }
43-
.still-works { color: white; }
44-
#primary { color: white; }
49+
// .js-class { color: white; }
50+
// .other-class { color: white; }
51+
// .still-works { color: white; }
52+
// #primary { color: white; }
4553
```

0 commit comments

Comments
 (0)