最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - gulp js src - copy and usage of base - Stack Overflow

programmeradmin9浏览0评论

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.

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.

Share Improve this question edited May 23, 2017 at 12:25 CommunityBot 11 silver badge asked Mar 27, 2014 at 0:07 Venkat ReddyVenkat Reddy 1,0521 gold badge8 silver badges13 bronze badges 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. – OverZealous Commented Mar 27, 2014 at 2:25
Add a ment  | 

2 Answers 2

Reset to default 21

The use of .src() is documented on the vinyl-fs github repo: https://github./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'))
;

You should try to use 'root' param instead:

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

评论列表(0)

  1. 暂无评论