I am working in node js application. I want to minify server js files. Am using gulp for that purpose.
var folders = ['business','config','controllers','model','routes','utilities']
gulp.task('minify', function() {
for(i=0;i<folders.length;i++){
gulp.src(folders[i]+'/*.js')
.pipe(rename({suffix: ""}))
.pipe(minify({ext:'.js'}))
.pipe(gulp.dest(folders[i]))
}
});
This is my gulp file. I need to minify the files in the folder without renaming or recreating any new file. But now it is creating in different folder and files will be appended with min suffix.
Is there any way to resolve this in gulp.
I tried this with both gulp-minify
and gulp-uglify
. gulp-minify
seems to be adding that suffix willingly.
You can use gulp-uglify
instead which worked for me:
gulp.src(folders[i]+'/*.js')
.pipe(uglify())
.pipe(gulp.dest(folders[i]))