1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- 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;
|