Hi everyone I hope you having a great day, I'm trying to find a way on how do I make a min
file in the same path or gulp.dest()
on gulp(gulp-uglify and gulp-rename). In my code below when I run my gulp it keeps on creating *.min.js
, *.min.min.js
, *.min.min.min.js
so on and so forth unless I stop the terminal. How do I make my gulp create only one *.min.js
at the same time it uglify's. I hope everyone can help me with this one. Thank You.
const gulp = require('gulp');
const browserSync = require('browser-sync').create();
const rename = require('gulp-rename');
const uglify = require('gulp-uglify');
gulp.task('scripts', function() {
return gulp.src('./src/js/*.js')
.pipe(uglify())
.pipe(rename( {suffix: '.min'} ))
.pipe(gulp.dest('./src/js/'))
.pipe(browserSync.stream());
});
gulp.task('browserSync', function(){
browserSync.init({
server : {
baseDir : './'
}
});
gulp.watch('./src/js/**.js', gulp.series('scripts'));
});
gulp.task('default', gulp.series('scripts', 'browserSync'));