10

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.

1
  • 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. Commented Mar 27, 2014 at 2:25

2 Answers 2

21

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'))
;
Sign up to request clarification or add additional context in comments.

Comments

-3

You should try to use 'root' param instead:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.