For each module I have some files that need to be copied over to the build directory, and am looking for a way to minimize the repeated code from this:
gulp.src('./client/src/modules/signup/index.js')
.pipe(gulp.dest('./build/public/js/signup'));
gulp.src('./client/src/modules/admin/index.js')
.pipe(gulp.dest('./build/public/js/admin'));
to something like this:
gulp.src('./client/src/modules/(.*)/index.js')
.pipe(gulp.dest('./build/public/js/$1'));
Obviously the above doesn't work, so is there a way to do this, or an npm that already does this?
Thanks
Use for preserve input directory tree will be preserved.
Using this, you can put in the src:
.src(SRC_FOLDER + '/**/*.js')
.The others answers not worked for me (like using
base:
onsrc()
}, because some plugins flatten the directory tree.Worked for me !
The best way is to configure your
base
when sourcing files, like so:This tells
gulp
to use the modules directory as the starting point for determining relative paths.(Also, you can use
/**/*.js
if you want to include all JS files...)Not the answer, but applicable to this question's appearance in search results.
To copy files/folders in gulp
copy files in parallel