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.
src() # The gulp. src() function takes a glob (i.e. a string matching one or more files) or an array of globs and returns a stream that can be piped to plugins. Gulp uses node-glob to get the files from the glob or globs you specify.
Gulp is a task runner that uses Node. js as a platform. Gulp purely uses the JavaScript code and helps to run front-end tasks and large-scale web applications. It builds system automated tasks like CSS and HTML minification, concatenating library files, and compiling the SASS files.
Gulpfile explained A gulpfile is a file in your project directory titled gulpfile. js (or capitalized as Gulpfile. js , like Makefile), that automatically loads when you run the gulp command.
Gulp plugins are Node Transform Streams that encapsulate common behavior to transform files in a pipeline - often placed between src() and dest() using the . pipe() method. They can change the filename, metadata, or contents of every file that passes through the stream.
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'))
;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With