Additionnaly to my above comment that I report here:
Note that if your task has to compile js into minified js, you would rather use 2 differents folders. As an example, a folder /source/js/ whose files are compiled in min.js into /dist/js/ ( or /public/js/ or anything you want ).
This a piece of code I often use to concatenate and uglify my Js files in most of my projects:
// My task called jsmin depend on another task, assume it is called clean but could be whatever
// That means that until the clean task is not completed, the jsmin task will not be executed.
gulp.task( 'jsmin', ['clean'], function() {
// First I clean the destination folder
del([ 'public/js/*' ]);
// Then I compile all the Js contained in source/js/ into min.js into public/js/
// In my example I concatenate all the Js together then I minimize them.
return gulp.src( 'source/js/*.js' )
.pipe(concat( "js.min.js" ))
.pipe(uglify())
.pipe(gulp.dest('public/js/'));
});
Hope that helps you.