Created
February 27, 2013 16:46
-
-
Save DimitarChristoff/5049406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var recess = require('recess'); | |
// need to fix recess. | |
(function(){ | |
var RECESS = recess.Constructor; | |
recess.Constructor.prototype.compile = function(){ | |
var that = this, | |
css; | |
// activate all relevant compilers | |
Object.keys(this.options).forEach(function(key){ | |
that.options[key] && RECESS.COMPILERS[key] && RECESS.COMPILERS[key].on.call(that); | |
}); | |
/* bug in recess messing up stuff is removed */ | |
// iterate over defintions and compress them (join with new lines) | |
/* | |
css = this.definitions.map(function (def) { | |
return def.toCSS([[]], { data: that.data, compress: that.options.compress }) | |
}).join(this.options.compress ? '' : '\n') */ | |
// instead use originals | |
css = this.data; | |
/* end bug removal and fix*/ | |
// minify with cssmin | |
if (that.options.compress) css = require('recess/lib/min').compressor.cssmin(css); | |
// deactivate all relevant compilers | |
Object.keys(this.options).reverse().forEach(function(key){ | |
that.options[key] && RECESS.COMPILERS[key] && RECESS.COMPILERS[key].off(); | |
}); | |
// cleanup trailing newlines | |
css = css.replace(/[\n\s\r]*$/, ''); | |
// output css | |
this.log(css, true); | |
// callback and exit | |
this.callback && this.callback(); | |
}; | |
}()); | |
// can now call it on files with ~" " expressions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment