const gulp = require('gulp'), concat = require('gulp-concat'), cleanCSS = require('gulp-clean-css'); purgecss = require('gulp-purgecss'), sass = require('gulp-sass')(require('sass')), browserSync = require('browser-sync').create(); function copy(cb) { gulp.src([ './node_modules/bootstrap/dist/js/bootstrap.bundle.min.js', './node_modules/swiper/swiper-bundle.min.js', ]) .pipe(gulp.dest('./_src/js/')); gulp.src([ './node_modules/bootstrap/dist/css/bootstrap.min.css', './node_modules/font-awesome/css/font-awesome.min.css', './node_modules/swiper/swiper.min.css', ]) .pipe(gulp.dest('./_src/css/')); console.log("Copy assets ๐Ÿ“ฆ "); cb(); } function build(cb) { gulp.src([ './css/fontawesome-all.min.css', './css/bootstrap.min.css', './css/swiper.css', './css/styles.css' ]) .pipe(concat('site.css')) .pipe(gulp.dest('./css/')); gulp.src([ './js/bootstrap.min.js', './js/swiper.min.js', './js/scripts.js' ]) .pipe(concat('site.js')) .pipe(gulp.dest('./js/')); console.log("Assets built ๐Ÿ”ง "); cb(); } function purge (cb) { gulp.src('./css/site.css') .pipe(purgecss({ content: ['./index.html'] })) .pipe(gulp.dest('./css/')); console.log("CSS purged ๐Ÿ› "); cb(); } function clean (cb) { gulp.src('./css/site.css') .pipe(cleanCSS({level: {1: {specialComments: 0}}})) .pipe(gulp.dest('./css/')); console.log("CSS cleaned ๐Ÿงน "); cb(); } function mixin() { return gulp.src('./css/*.scss') .pipe(sass().on('error',sass.logError)) .pipe(gulp.dest('./css/')) .pipe(browserSync.stream()); } function run() { browserSync.init({ server: { baseDir: "./", index: "/index.html" } }); function reload() { browserSync.reload(); } gulp.watch('./css/*.scss', mixin); gulp.watch([ './css/styles.css', './js/scripts.js' ]).on('change',gulp.series(build,purge, clean, reload)); gulp.watch('./index.html').on('change',reload); console.log("๐Ÿ”ฅ Run"); } exports.copy = copy; exports.build = build; exports.purge = purge; exports.clean = clean; exports.mixin = mixin; exports.run = run;