const gulp = require('gulp'), useref = require('gulp-useref'), gulpif = require('gulp-if'), terser = require('gulp-terser'), sass = require('gulp-sass')(require('sass')), cleanCSS = require('gulp-clean-css'), htmlmin = require('gulp-htmlmin'), rename = require("gulp-rename"), concat = require("gulp-concat"), browserSync = require('browser-sync').create(); function copy(cb) { gulp.src('./node_modules/bootstrap/dist/js/bootstrap.bundle.js') .pipe(gulp.dest('./js/')); gulp.src('./node_modules/bootstrap/dist/js/bootstrap.bundle.js.map') .pipe(gulp.dest('./js/')); gulp.src('./node_modules/bootstrap-icons/font/fonts/*') .pipe(gulp.dest('./css/_font/')); gulp.src('./node_modules/jquery/dist/jquery.min.js') .pipe(gulp.dest('./js/')); gulp.src('./node_modules/fullcalendar/main.js') .pipe(rename('fullcalendar.js')) .pipe(gulp.dest('./js/', { overwrite:true } )); gulp.src('./node_modules/fullcalendar/main.css') .pipe(rename('fullcalendar.css')) .pipe(gulp.dest('./css/', { overwrite:true } )); gulp.src('./node_modules/waypoints/lib/noframework.waypoints.js') .pipe(rename('waypoints.js')) .pipe(gulp.dest('./js/')); gulp.src('./node_modules/waypoints/lib/shortcuts/inview.js') .pipe(rename('waypoints-inview.js')) .pipe(gulp.dest('./js/')); console.log("files 📄 from npm pkgs "); cb(); } function build(cb) { gulp.src('index.html') .pipe(useref()) .pipe(gulpif('*.js', terser())) .pipe(gulpif('*.css', cleanCSS({level: {1: {specialComments: 0}}}))) .pipe(gulp.dest('./app/')); console.log("Assets built 🔧 for app/ "); cb(); } function html(cb) { return gulp.src('./app/index.html') .pipe(htmlmin({ collapseWhitespace: true, removeComments:true })) .pipe(gulp.dest('./app/index.min.html')); cb(); } function mixin(cb) { return gulp.src('./css/**/*.scss') .pipe(sass().on('error',sass.logError)) .pipe(gulp.dest('./css/')) .pipe(browserSync.stream()); cb(); } function reload(cb) { browserSync.reload(); cb(); } function run() { browserSync.init({ server: { baseDir: "./", index: "/index.html" } }); gulp.watch('./css/*.scss', mixin); gulp.watch('./css/**/*.css').on('change', browserSync.reload); gulp.watch('./*.html').on('change',browserSync.reload); gulp.watch('./js/**/*.js').on('change', gulp.series(build, reload)); } exports.copy = copy; exports.build = build; exports.mixin = mixin; exports.run = run;