开发者

LESS @import: Passing paths to lessc

I'd like to use LESS stylesheets in a parent and child theme, in which most of the stylesheet information is specified by the parent and the child simply overrides a few files. This is possib开发者_StackOverflowle with the Ruby version of LESS like so:

var parser = new(less.Parser)({
    paths: ['.', './lib'], // Specify search paths for @import directives
    filename: 'style.less' // Specify a filename, for better error messages
});

but is it possible with the command line compiler lessc? I'd like to say:

$ lessc --path=".;../parent" style.less


Looking at the lessc source code:

    case 'include-path':
        options.paths = match[2].split(':')
            .map(function(p) {
                if (p && p[0] == '/') {
                    return path.join(path.dirname(input), p);
                } else if (p) {
                    return path.join(process.cwd(), p);
                }
            });
        break;

You can pass multiple paths to lessc. So the correct syntax for your example is:

lessc --include-path=".:../parent" style.less


Marcus

There's a --include-path switch that you can use.

lessc --include-path=./inc/ main.less

Note, it needs to be relative to the path that lessc is executing in.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜