Skip to content

Instantly share code, notes, and snippets.

@jack4it
Created December 26, 2015 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jack4it/3c1451b8913edc2f1efb to your computer and use it in GitHub Desktop.
Save jack4it/3c1451b8913edc2f1efb to your computer and use it in GitHub Desktop.
exports.translate = function (load) {
return System.import("less/lib/less-browser")
.then(function (lesscWrapper) {
return lesscWrapper(window, {
async: true,
errorReporting: "Console"
});
})
.then(function (lessc) {
return lessc.render(load.source, {
filename: load.name.replace(/^file:(\/+)?/i, '')
});
})
.then(function (output) {
// output.css = string of css
// output.map = string of sourcemap
// output.imports = array of string filenames of the imports referenced
var style = document.createElement('style');
style.setAttribute('type', 'text/css');
style.textContent = output.css;
document.getElementsByTagName('head')[0].appendChild(style);
load.metadata.format = 'defined';
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment