LESS @import:将路径传递给lessc [英] LESS @import: Passing paths to lessc

查看:387
本文介绍了LESS @import:将路径传递给lessc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在父和子主题中使用LESS样式表,其中大部分样式表信息由父项指定,子项简单地覆盖了几个文件。这是可能的LESS的Ruby版本像这样:

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

但可以使用命令行编译器 lessc ?我想说:

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

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


推荐答案

查看lessc源代码:

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;

您可以将多个路径传递给lessc。因此,您的示例的正确语法是:

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

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

这篇关于LESS @import:将路径传递给lessc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆