Skip to content
Browse files

add clean-css

  • Loading branch information...
1 parent 2141ad4 commit ef7a8a39011af4b429bb12f5be1fded3e130de44 @lancejpollard lancejpollard committed Apr 15, 2012
Showing with 42 additions and 3 deletions.
  1. +17 −0 mint.js
  2. +3 −3 package.json
  3. +14 −0 src/mint.coffee
  4. +8 −0 test/mintTest.coffee
View
17 mint.js
@@ -293,6 +293,23 @@
}
return result;
},
+ cleanCSS: function(content, options, callback) {
+ var error, path, result;
+ path = options.path;
+ error = null;
+ try {
+ result = require("clean-css").process(content);
+ } catch (e) {
+ error = e;
+ if (path) {
+ error.message += ", " + path;
+ }
+ }
+ if (callback) {
+ callback.call(this, error, result);
+ }
+ return result;
+ },
uglifyjs: function(content, options, callback) {
var ast, compressor, error, parser, path, result;
path = options.path;
View
6 package.json
@@ -32,6 +32,7 @@
"devDependencies": {
"coffee-script": ">= 1.3.1",
"uglify-js": ">= 1.1.1",
+ "clean-css": ">= 0.3.2",
"mocha": ">= 0.8.1",
"should": ">= 0.3.x",
"chai": ">= 0.3.3",
@@ -45,9 +46,8 @@
"hamljs": ">= 0.6.x",
"haml-coffee": ">= 0.5.0",
"mustache": ">= 0.4.x",
- "handlebars": "*",
- "eco": "*"
-
+ "handlebars": "*",
+ "eco": "*"
},
"scripts": {
"test": "node_modules/mocha/bin/mocha $(find test -name \"*Test.coffee\")"
View
14 src/mint.coffee
@@ -222,7 +222,21 @@ module.exports =
callback.call(@, error, result) if callback
result
+
+ cleanCSS: (content, options, callback) ->
+ path = options.path
+ error = null
+ try
+ result = require("clean-css").process(content)
+ catch e
+ error = e
+ error.message += ", #{path}" if path
+
+ callback.call(@, error, result) if callback
+
+ result
+
uglifyjs: (content, options, callback) ->
path = options.path
error = null
View
8 test/mintTest.coffee
@@ -19,6 +19,14 @@ $(document).ready(function() {
assert.equal mint.engine(".styl"), "stylus"
assert.equal mint.engine("styl"), "stylus"
assert.equal mint.engine("eco"), "eco"
+
+ it "should render minified with clean-css", (done) ->
+ input = "body { background: red; }"
+ output = "body{background:red}"
+
+ mint.cleanCSS input, {}, (error, result) ->
+ assert.equal result, output
+ done()
it "should render minified css with yui", (done) ->
input = "body { background: red; }"

0 comments on commit ef7a8a3

Please sign in to comment.
Something went wrong with that request. Please try again.