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

Added: compress option used cssnano instead of CSSWring #127

Merged
merged 1 commit into from
May 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.5.0 - 2015-05-23

- Added: `compress` option used cssnano instead of CSSWring.

# 1.4.0 - 2015-05-01

- Added: support for `:matches()` selector pseudo class
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ _Note: you can pass [postcss-url options](https://github.com/postcss/postcss-url

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

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

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

Expand Down
13 changes: 11 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,17 @@ function cssnext(string, options) {

// minification
if (options.compress) {
var csswring = require("csswring")
postcssInstance.use(typeof options.compress === "object" ? csswring(options.compress) : csswring)
var nano = require("cssnano")

/* forced calc options to false */
if (typeof options.compress === "object") {
options.compress.calc = false
}
else {
options.compress = {calc: false}
}

postcssInstance.use(nano(options.compress))
}

// classic API if string is passed
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cssnext",
"version": "1.4.0",
"version": "1.5.0",
"description": "Use tomorrow's CSS syntax, today",
"keywords": [
"css",
Expand Down Expand Up @@ -32,7 +32,7 @@
"chokidar": "^1.0.0",
"colors": "^1.0.2",
"commander": "^2.3.0",
"csswring": "^3.0.0",
"cssnano": "^1.2.0",
"exit": "^0.1.2",
"object-assign": "^2.0.0",
"pixrem": "^1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ test("cli", function(t) {

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

Expand Down
2 changes: 1 addition & 1 deletion test/option.compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test("cssnext compress option", function(t) {

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

t.end()
Expand Down