Created
December 26, 2015 23:12
-
-
Save jack4it/3c1451b8913edc2f1efb 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
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