Gulp uglify output min.js

user1995781 picture user1995781 · Jan 13, 2015 · Viewed 26.3k times · Source

The js file being compressed is output with the same filename.

gulp.task('compressjs', function () {
  gulp.src('app/**/*.js')
    .pipe(uglify())
    .pipe(gulp.dest('dist'));
});

How can I have it output the file with min.js at the back?

Answer

Balthazar picture Balthazar · Jan 13, 2015

You can use the suffix or extname parameters of gulp-rename like:

gulp.task('compressjs', function () {
  gulp.src('app/**/*.js')
    .pipe(uglify())
    .pipe(rename({ suffix: '.min' }))
    .pipe(gulp.dest('dist'))
})