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

Commit eb364da

Browse files
committed
Added: compress option used cssnano instead of CSSWring
Close #94
1 parent d189cf4 commit eb364da

File tree

6 files changed

+21
-8
lines changed

6 files changed

+21
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.5.0 - 2015-05-23
2+
3+
- Added: `compress` option used cssnano instead of CSSWring.
4+
15
# 1.4.0 - 2015-05-01
26

37
- Added: support for `:matches()` selector pseudo class

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ _Note: you can pass [postcss-url options](https://github.com/postcss/postcss-url
306306

307307
##### `compress` (default: `false`)
308308

309-
Allows you to compress the output (using [CSSWring](https://github.com/hail2u/node-csswring)).
310-
You can enable minification by passing `true` or by providing an object containing [CSSWring options](https://github.com/hail2u/node-csswring#options).
309+
Allows you to compress the output (using [cssnano](https://github.com/ben-eb/cssnano)).
310+
You can enable minification by passing `true` or by providing an object containing [cssnano options](https://github.com/ben-eb/cssnano#options).
311311

312312
##### `sourcemap` (default: `false`)
313313

index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,17 @@ function cssnext(string, options) {
141141

142142
// minification
143143
if (options.compress) {
144-
var csswring = require("csswring")
145-
postcssInstance.use(typeof options.compress === "object" ? csswring(options.compress) : csswring)
144+
var nano = require("cssnano")
145+
146+
/* forced calc options to false */
147+
if (typeof options.compress === "object") {
148+
options.compress.calc = false
149+
}
150+
else {
151+
options.compress = {calc: false}
152+
}
153+
154+
postcssInstance.use(nano(options.compress))
146155
}
147156

148157
// classic API if string is passed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cssnext",
3-
"version": "1.4.0",
3+
"version": "1.5.0",
44
"description": "Use tomorrow's CSS syntax, today",
55
"keywords": [
66
"css",
@@ -32,7 +32,7 @@
3232
"chokidar": "^1.0.0",
3333
"colors": "^1.0.2",
3434
"commander": "^2.3.0",
35-
"csswring": "^3.0.0",
35+
"cssnano": "^1.2.0",
3636
"exit": "^0.1.2",
3737
"object-assign": "^2.0.0",
3838
"pixrem": "^1.1.0",

test/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ test("cli", function(t) {
9090

9191
exec(cssnextBin + " --compress test/fixtures/compress.css", function(err, stdout) {
9292
if (err) { throw err }
93-
t.equal(stdout, utils.readFixture("compress.default.expected").trim(), "should compress on --compress")
93+
t.equal(stdout.trim(), utils.readFixture("compress.default.expected").trim(), "should compress on --compress")
9494
})
9595
planned += 1
9696

test/option.compress.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test("cssnext compress option", function(t) {
1616

1717
// compress option
1818
t.equal(cssnext(input, {compress: true}).trim(), expected.default, "should be able to compress")
19-
t.equal(cssnext(input, {compress: {removeAllComments: true}}).trim(), expected.options, "should be able to compress with options")
19+
t.equal(cssnext(input, {compress: {comments: {removeAll: true}}}).trim(), expected.options, "should be able to compress with options")
2020
t.equal(postcss().use(cssnext({compress: true})).process(input).css.trim(), expected.default, "should be able to compress even as a postcss plugin")
2121

2222
t.end()

0 commit comments

Comments
 (0)