Skip to content

Instantly share code, notes, and snippets.

@maccman
Created October 29, 2011 13:07
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save maccman/1324427 to your computer and use it in GitHub Desktop.
Save maccman/1324427 to your computer and use it in GitHub Desktop.
Hem & Less
var hem = new (require('hem'));
var less = require('less');
var fs = require('fs');
var argv = process.argv.slice(2);
hem.compilers.less = function(path) {
var content, result;
content = fs.readFileSync(path, 'utf8');
result = '';
less.render(content, function(err, css) {
if (err) { throw err; }
result = css;
});
return result;
};
require.extensions['.less'] = function(module, filename) {
var source;
source = JSON.stringify(hem.compilers.less(filename));
return module._compile("module.exports = " + source, filename);
};
hem.exec(argv[0]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment