jspm-less-plugin icon indicating copy to clipboard operation
jspm-less-plugin copied to clipboard

Does the build work?

Open wclr opened this issue 10 years ago • 8 comments

Does this plugin work for systemjs-builder? There is no node less.js dependency.

wclr avatar Feb 22 '15 01:02 wclr

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.

Aaike avatar Feb 22 '15 10:02 Aaike

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)
            }
        });
    });
};

wclr avatar Feb 22 '15 13:02 wclr

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 ;)

Aaike avatar Mar 03 '15 21:03 Aaike

@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 avatar Mar 23 '15 18:03 theefer

@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.

wclr avatar Mar 24 '15 08:03 wclr

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.

theefer avatar Mar 24 '15 11:03 theefer

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

jack4it avatar Dec 14 '15 17:12 jack4it

I created a pull request to fix the bundling bug AND version the plugin along with the different versions of less.

justingorham avatar Mar 05 '16 03:03 justingorham