10
votes

I have gulp task to copy js files

This doesn't work

gulp.src('./**/*.js', {base: '../src/main/'})
    .pipe(gulp.dest('../target/dist'));

This works:

gulp.src('../src/main/**/*.js', {base: '../src/main/'})
        .pipe(gulp.dest('../target/dist'));

So whats the use of base here ? if i have to put whole path in first param, why should i use base ?

is there any official documentation about gulp src ? is it worth using gulp over grunt with limited documentation ?

[UPDATE BASED ON COMMENT]
Why am i using base ?

Please read this Looking for way to copy files in gulp and rename based on parent directory

and moreoever gulp.src can take array of paths so i would need base.

2
Why are you using base in the first place? It's not in the docs because it's not used except in special circumstances. gulp.src is in the API docs, base is documented via glob-stream. - OverZealous

2 Answers

21
votes

The use of .src() is documented on the vinyl-fs github repo: https://github.com/wearefractal/vinyl-fs

The base property is used to determine the file names when saving in .dest().

I think you need to set the current working directory:

gulp
  .src('./**/*.js', {cwd: '../src/main/'})
  .pipe(gulp.dest('../target/dist'))
;
-3
votes

You should try to use 'root' param instead:

 gulp.src('./**/*.js', {root: '../src/main/'})
     .pipe(gulp.dest('../target/dist'));