Upon reading this post, checking out this package's documentation, and learning about globs here, I am struggling to figure out how to modify the code snippet below to filter only the JavaScript files without including their parent folders:
gulp.task("distribution", function () {
return gulp.src("distribution/**/*.js", { nodir: true })
.pipe(gulp.dest("www/javascripts"));
});
The current file structure looks like this:
javascripts/bootstrap/dist/js/bootstrap.js
javascripts/hammerjs/hammer.js
javascripts/jquery/dist/jquery.js
javascripts/localforage/dist/localforage.js
javascripts/moment/moment.js
javascripts/vue/dist/vue.js
javascripts/vue-touch/vue-touch.js
But what I want is to achieve the following structure:
javascripts/bootstrap.js
javascripts/hammer.js
javascripts/jquery.js
javascripts/localforage.js
javascripts/moment.js
javascripts/vue.js
javascripts/vue-touch.js
I've tried implementing the following code with no success:
gulp.task("distribution", function () {
const filterToApply = filter("*.js", { restore: true });
return gulp.src("distribution/**")
.pipe(filterToApply)
.pipe(gulp.dest("www/javascripts"));
});
And using this alternative approach resulted in the same output as the original one:
gulp.task("distribution", function () {
const filterToApply = filter("**/*.js", { restore: true });
return gulp.src("distribution/**")
.pipe(filterToApply)
.pipe(gulp.dest("www/javascripts"));
});