消glob和否定 [英] Gulp globbing and negate

查看:146
本文介绍了消glob和否定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的结构是这样的:

  + dir3 
- dir3.1
- dir3.1.1
- dir3.1.2
- dir3 .2
- dir3.3
- responsive.less
- fixedwidths.less

每个目录都有一组较少的文件,我想要做的是编译responsive.less和fixedwidths.less,但我想忽略 dir3中的所有其余文件夹 code>。



用于编译少量文件的Gulp Glob是:

  var paths = {
root:'Publication /',
source:'Publication / LESS /',
styles:'Publication / ** / *。less'

$ b编译更少的文件
gulp.task('styles',function(){
gulp.src([
paths.source +'* * / *。less',//编译全部
'!'+ paths.source +'** / variables.less',//忽略所有变量。
paths.source +'responsive / *。less',//编译响应&固定宽度
'!'+ paths.source +'responsive / ** / *。less'//忽略dir3的子目录中的所有较少文件
])
.pipe(less())
.pipe(gulp.dest(paths.root +'build'))
});

我在期待 paths.source +'responsive / *。less'会匹配responsive.less和fixedwidths.less和'!'+ paths.source +'responsive / ** / *。less'会忽略其他所有内容但那不是似乎正在发生的事情。后一位代码似乎阻止了dir3的所有处理。



什么可以帮助?

解决方案

节点glob中存在与否定glob模式相关的错误。请参阅凉亭问题 node-glob问题。也许你的问题与此有关?



如果是这样,这个解决方法应该工作'./!('+ paths.source +'responsive / * * / *。less)'


I'm having an issue where I'm unable to compile a set of LESS file using Globbing.

My structure is this:

+ dir3
  - dir3.1
    - dir3.1.1
    - dir3.1.2
  - dir3.2
  - dir3.3
  - responsive.less
  - fixedwidths.less

Each dir has a set of less files and what I'm trying to do is to compile responsive.less and fixedwidths.less but i want to ignore all the remaining folders in dir3.

My Gulp Glob for compiling less files is:

var paths = {
    root: 'Publication/',
    source: 'Publication/LESS/',
    styles: 'Publication/**/*.less'
}

// Compile less files
gulp.task('styles', function() {
    gulp.src([
            paths.source+'**/*.less', // compile it all
            '!'+paths.source+'**/variables.less', // ignore all variables.less
            paths.source+'responsive/*.less', // compile responsive & fixedwidths
            '!'+paths.source+'responsive/**/*.less' // ignore all less files in subdir of dir3
        ])
        .pipe(less())
        .pipe(gulp.dest(paths.root+'build'))
});

I was expecting that paths.source+'responsive/*.less' would match responsive.less and fixedwidths.less and '!'+paths.source+'responsive/**/*.less' would ignore everything else but that's not what seems to be happening. The latter bit code seems to halt all processing of dir3.

Can anything help?

解决方案

There is a bug in node-glob related to negated glob patterns. See this bower issue and this node-glob issue. Maybe your problem is related to this?

If so, this workaround should work './!('+paths.source+'responsive/**/*.less)'.

这篇关于消glob和否定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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