简体   繁体   English

gulp.src模式仅匹配最后一个文件

[英]gulp.src pattern only matches last file

I am trying to browserify all my 'spec' files in my tests folder, 我正在尝试浏览我的测试文件夹中的所有“规范”文件,

gulp.task('browserifyTests',function(){
return gulp.src(['./tests/**/spec*.js'])
    .pipe($$.browserify()
    )
    .pipe($$.rename('specs.bundle.js'))
    .pipe(gulp.dest('tests'));

}); });

I have 2 files specA.js and specB.js under tests/specs folder. 我在tests / specs文件夹下有2个文件specA.js和specB.js。 When I browserify, I only see specB.js in the specs.bundle.js. 当我浏览器化时,我仅在specs.bundle.js中看到specB.js。 Its really baffling why such a thing should happen when the pattern should clearly match here right? 真正令人困惑的是,当模式在此处明显匹配时,为什么会发生这种事情呢? Or am I doing something silly.. Actually, I did a gulp-print and I see both file names printed too. 还是我在做些愚蠢的事情。.实际上,我做了一张gulp-print,并且看到两个文件名也都打印了。

AFAIK, you can't use Browserify in Gulp like that (because it's not a Gulp plugin). AFAIK,您不能像那样在Gulp中使用Browserify(因为它不是Gulp插件)。

Try this: 尝试这个:

const source = require('vinyl-source-stream');
const glob   = require('glob').sync;

gulp.task('js', () => {
  return $$.browserify(glob('./tests/**/spec*.js'), {...})
           .bundle()
           .pipe(source('specs.bundle.js'))
           .pipe(gulp.dest('./tests/'));
});

More info here (in particular, "Using them together: Gulp + Browserify" ). 这里有更多信息(尤其是“一起使用:Gulp + Browserify” )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM