const { src, dest, series, parallel, watch } = require('gulp'); const uglify = require('gulp-uglify'); const cleanCss = require('gulp-clean-css'); const browserSync = require('browser-sync').create(); function genHTML(cb) { console.log('HTML másolás...'); src('src/**/*.html') .pipe(dest('public')) cb(); } function minifyJS(cb) { console.log('JavaScript minifikálás ...'); src('src/**/*.js') .pipe(uglify()) .pipe(dest('public')); cb(); } function minifyCSS(cb) { console.log('CSS minifikálás ...'); src('src/**/*.css') .pipe(cleanCss()) .pipe(dest('public')); cb(); } function build(cb) { parallel(genHTML, minifyJS, minifyCSS)(cb); } function devServe(cb) { browserSync.init({ server: [ "src", "node_modules/bootstrap/dist/css", "node_modules/bootstrap/dist/js" ] }); watch('src/**/*').on('change', browserSync.reload); cb(); } function prodServe(cb) { browserSync.init({ server: { baseDir: './public' }, port: 3500 }); watch('public/**/*').on('change', browserSync.reload); cb(); } exports.build = build; exports.serve = devServe; exports.serve = prodServe; exports.default = series(build, devServe);