'use strict'; var gulp = require('gulp'); var watch = require('gulp-watch'); var jsmin = require('gulp-jsmin'); var rename = require('gulp-rename'); function handleError(err) { console.log(err.toString()); // this.emit('end'); } gulp.task('scripts', done => { gulp.src('./js/*.js') .pipe(jsmin()) .pipe(rename({suffix: '.min'})) .pipe(gulp.dest('./js/dist/')); done() }); // default gulp task gulp.task('default', gulp.series('scripts', function(done) { gulp.watch('./js/*.js', gulp.series('scripts')); done() }));