Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Commit 3fb1202

Browse files
committed
Add compress option
Close #14
1 parent 7c12b76 commit 3fb1202

File tree

6 files changed

+32
-0
lines changed

6 files changed

+32
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ See [autoprefixer documentation of this option for more details](https://github.
130130

131131
Default to something like `["> 1%", "last 2 versions", "Firefox ESR"]`.
132132

133+
##### `compress` (default: `false`)
134+
135+
Allow you to compress the output (using [CSSWring](https://github.com/hail2u/node-csswring)).
136+
133137
##### `sourcemap` (default: `false`)
134138

135139
**If you want a accurate sourcemap, please use instead the `from` option.**

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ function cssnext(string, options) {
5454
}
5555
})
5656

57+
// simple minifier plugin
58+
if (options.compress) {
59+
postcss.use(require("csswring").postcss)
60+
}
61+
5762
return postcss.process(string, options).css
5863
}
5964

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
],
2929
"dependencies": {
3030
"autoprefixer": "^2.2.0",
31+
"csswring": "^1.0.0",
3132
"postcss": "^2.1.0",
3233
"postcss-calc": "^2.0.1",
3334
"postcss-color": "^1.0.0",

test/compress/expected.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
body{color:red}

test/compress/input.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
/* blah */
3+
body {
4+
color : red;
5+
}

test/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,22 @@ Object.keys(cssnext.features).forEach(function(name) {
4848
})
4949
})
5050

51+
/**
52+
* Compress tests
53+
*/
54+
test("compress", function(t) {
55+
t.equal(
56+
cssnext(
57+
read("compress/input"),
58+
{compress: true}
59+
).trim(),
60+
read("compress/expected").trim(),
61+
"should compress on --compress (thanks Captain Obvious)"
62+
)
63+
64+
t.end()
65+
})
66+
5167
/**
5268
* Sourcemap tests
5369
*/

0 commit comments

Comments
 (0)