jspm-less-plugin
jspm-less-plugin copied to clipboard
Does the build work?
Does this plugin work for systemjs-builder? There is no node less.js dependency.
Hi , yes there is a less-builder.js : https://github.com/Aaike/jspm-less-plugin/blob/master/less-builder.js It is atuomatically used when bundling. It has not been tested but it should function just the same as the official css-plugin.
If you have any problems with it please let me know and i will look into it.
You should test it, it doesn't work =) as you use browser version to build in node, it won't work.
my plugin code, for build only:
var css = require('css');
var less = require('npm:[email protected]');
exports.bundle = css.bundle
exports.translate = function(load) {
var options = System.less || {}
// Add compress default `true` option
options.compress = options.compress == undefined ? true : options.compress
// Add baseURL directory and current file directory in the paths
var base = System.baseURL.replace(/^file:/, ''),
dir = load.address.replace(/[^\/\\]*$/, '').replace(/^file:/, '')
options.paths = (options.paths || []).concat(base, dir);
load.metadata.format = 'defined';
return new Promise(function(resolve, reject){
less.render(load.source, options, function (err, output) {
if(err){
console.error('less-plugin', err)
reject(err)
} else {
resolve(output.css)
}
});
});
};
I'm currently very busy with projects that need finishing :) i will look into it when i find some time , but i don't know when that will be. If anybody wants to work on the builder, i will happily accept PR's ;)
@whitecolor Do you have a full branch or example of this working? I'm really interested but can't seem to get your example to work locally.
@theefer no I dont' currenlty. It was a manual tune up of systemjs-builder workflow (there is also an issue with image-size package https://github.com/jspm/registry/issues/221). I currently use stealJS (http://stealjs.com/) in production, you may try it, this is loader on top of System.js. It supports less/css and multiple bundling out of the box, which systemjs-builder desn't currenlty.
I'll take a look, thanks!
It doesn't seem like it should be too hard to fix the less-builder.js script in a similar way to what you've done, though I still need to spend some time on it. Will open a PR if I get anything working.
The builder part of this plugin here doesn't seem to work still, I just tried.
I wrote a LESS plugin as well before I actually noticed this one. I have made both browser/build scenarios work. Just in case you guys are interested, here is the link https://github.com/jack4it/system-less
I created a pull request to fix the bundling bug AND version the plugin along with the different versions of less.