Skip to content

Commit dc225f2

Browse files
committed
Initial commit
0 parents  commit dc225f2

File tree

5 files changed

+137
-0
lines changed

5 files changed

+137
-0
lines changed

.gitignore

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
11+
# Directory for instrumented libs generated by jscoverage/JSCover
12+
lib-cov
13+
14+
# Coverage directory used by tools like istanbul
15+
coverage
16+
17+
# nyc test coverage
18+
.nyc_output
19+
20+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21+
.grunt
22+
23+
# node-waf configuration
24+
.lock-wscript
25+
26+
# Compiled binary addons (http://nodejs.org/api/addons.html)
27+
build/Release
28+
29+
# Dependency directories
30+
node_modules
31+
jspm_packages
32+
33+
# Optional npm cache directory
34+
.npm
35+
36+
# Optional REPL history
37+
.node_repl_history

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright 2016 Ryan Zimmerman <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# postcss-uncss
2+
3+
Use [giakki/uncss](https://github.com/giakki/uncss) as a [PostCSS](https://github.com/postcss/postcss) plugin.
4+
5+
## About
6+
7+
UnCSS is a tool that removes unused CSS from your stylesheets. It works across multiple files and supports Javascript-injected CSS.
8+
9+
### How?
10+
11+
The HTML files are loaded by [PhantomJS](https://github.com/Obvious/phantomjs) and JavaScript is executed. UnCSS filters out selectors that are not found in the HTML files.
12+
13+
See the [UnCSS](https://github.com/giakki/uncss) docs for more information.
14+
15+
## Installation
16+
17+
```bash
18+
npm install postcss-uncss
19+
```
20+
21+
## Usage
22+
23+
```js
24+
postcss([ require('postcss-uncss') ])
25+
```
26+
27+
See [PostCSS](https://github.com/postcss/postcss) docs for examples for your environment.
28+
29+
## Options
30+
31+
- **html** (Array): provide a list of html files to parse for selectors and elements. Usage of [globs](https://github.com/isaacs/node-glob) is allowed.
32+
33+
- **ignore** (Array): provide a list of selectors that should not be removed by UnCSS. For example, styles added by user interaction with the page (hover, click), since those are not detectable by UnCSS yet. Both literal names and regex patterns are recognized. Otherwise, you can add a comment before specific selectors in your css:
34+
35+
```css
36+
/* uncss:ignore */
37+
.selector1 {
38+
/* this rule will be ignored */
39+
}
40+
41+
.selector2 {
42+
/* this will NOT be ignored */
43+
}
44+
```
45+
46+
### Example Configuration
47+
48+
```js
49+
{
50+
html: ['index.html', 'about.html', 'team/*.html'],
51+
ignore: ['.fade']
52+
}
53+
```

index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports=require('uncss').postcssPlugin;

package.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "postcss-uncss",
3+
"version": "0.0.1",
4+
"description": "Use giakki/uncss as a postcss plugin",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/RyanZim/postcss-uncss.git"
12+
},
13+
"keywords": [
14+
"postcss-plugin",
15+
"uncss"
16+
],
17+
"author": "Ryan Zimmerman <[email protected]> (http://ryanzim.com/)",
18+
"license": "MIT",
19+
"bugs": {
20+
"url": "https://github.com/RyanZim/postcss-uncss/issues"
21+
},
22+
"homepage": "https://github.com/RyanZim/postcss-uncss#readme",
23+
"dependencies": {
24+
"uncss": "github:giakki/uncss#50cb679572d4723315f02c7e7fdbdaadf32021d0"
25+
}
26+
}

0 commit comments

Comments
 (0)