const { task, series, parallel, src, dest, watch } = require('gulp'); const babel = require('gulp-babel'); const uglify = require('gulp-uglify'); const concat = require('gulp-concat'); const clean = require('gulp-clean'); const livereload = require('gulp-livereload'); const cleanTask = function () { return src('dist/*', { read: false }).pipe(clean()); }; const script = function () { return src('src/**/*.js') .pipe(babel({ presets: ['@babel/env'] })) .pipe(uglify()) .pipe(concat('main.js')) .pipe(dest('dist/')) .pipe(livereload({ start: true, port: 3001, reloadPage: 'dist/index.html' })); }; const copy = function () { src('./public/index.html').pipe(dest('dist/')); src('./public/bird.js').pipe(dest('dist/')); src('./public/images/*').pipe(dest('dist/images')); src('./public/libs/**/*').pipe(dest('dist/libs')); src('./public/sounds/*').pipe(dest('dist/sounds')); }; const watchTask = function () { livereload.listen(); watch('src/*', script); }; exports.default = parallel(copy, script, watchTask);