Looking for way to copy files in gulp and rename based on parent directory
Not the answer, but applicable to this question's appearance in search results.
To copy files/folders in gulp
gulp.task('copy', () => gulp
.src('index.js')
.pipe(gulp.dest('dist'))
);
The best way is to configure your base
when sourcing files, like so:
gulp.src('./client/src/modules/**/index.js', {base: './client/src/modules'})
.pipe(gulp.dest('./build/public/js/'));
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...)
return gulp.src('./client/src/modules/(.*)/index.js')
.pipe(gulp.dest('./build/public/js/$1'));
Worked for me !