简体   繁体   中英

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. When I browserify, I only see specB.js in the specs.bundle.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.

AFAIK, you can't use Browserify in Gulp like that (because it's not a Gulp plugin).

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" ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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