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