将一个目录中的所有less文件导入到一个less文件中。

4

我有以下目录结构的less文件:

   vendor/includes/file1.less
   vendor/includes/file1.less
   vendor/includes/file1.less
   vendor/includes/file1.less

我想将以下目录结构中的文件导入到我的主 less 文件中:
```less ```
请注意,这里保留了 HTML 标签,请勿删除。
  vendor/main.less

目前我使用的@import不起作用,如下:

main.less

@import "includes/";

有什么建议吗? 注意:我正在使用Elixir通过Gulp编译


3
请参阅less-plugin-glob - seven-phases-max
1个回答

1

我只是复制并详细说明了seven-phases-max的评论,因为这是我正在寻找的答案。

使用less-plugin-glob

  1. Install the npm package with npm install --save-dev less-plugin-glob
  2. Pass the plugin to the less() function call in your gulpfile:

    .pipe(less({
        plugins: [require('less-plugin-glob')]
    }))
    
  3. Use glob patterns in your imports:

    @import "includes/*.less";
    

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接