123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- const gulp = require('gulp'),
- concat = require('gulp-concat'),
- purgecss = require('gulp-purgecss'),
- sourcemaps = require('gulp-sourcemaps'),
- 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/bootstrap/dist/js/bootstrap.bundle.min.js.map'
- //])
- // .pipe(gulp.dest('./js/'));
- gulp.src([
- './node_modules/animate.css/animate.css'
- // './node_modules/bootstrap/dist/css/bootstrap.min.css',
- // './node_modules/bootstrap/dist/css/bootstrap.min.css.map',
- // './node_modules/bootstrap-icons/font/bootstrap-icons.css'
- ])
- .pipe(gulp.dest('./css/'));
- gulp.src([
- './node_modules/bootstrap-icons/font/fonts/bootstrap-icons.woff',
- './node_modules/bootstrap-icons/font/fonts/bootstrap-icons.woff2',
- ])
- .pipe(gulp.dest('./css/fonts/'));
- console.log("Copy assets ๐ฆ ");
- cb();
- }
- function build(cb) {
- gulp.src([
- './css/styles.css',
- './css/custom.css'
- ])
- .pipe(concat('site.css'))
- .pipe(gulp.dest('./css/'));
- gulp.src([
- './node_modules/bootstrap/dist/js/bootstrap.bundle.min.js',
- './js/scripts.js'
- ])
- .pipe(concat('site.js'))
- .pipe(sourcemaps.init())
- .pipe(sourcemaps.write('.'))
- .pipe(gulp.dest('./js/'));
- console.log("Assets built ๐ง ");
- cb();
- }
- function purge (cb) {
- gulp.src('./css/site.css')
- .pipe(purgecss({
- content: ['./*.html', './js/*.js']
- }))
- .pipe(sourcemaps.init())
- .pipe(sourcemaps.write('.'))
- .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', { sourcemaps: true })
- .pipe(sass().on('error',sass.logError))
- .pipe(gulp.dest('./css/'))
- .pipe(browserSync.stream());
- }
- function reload(cb) {
- browserSync.reload();
- cb();
- }
- function run() {
- browserSync.init({
- server: {
- baseDir: "./",
- index: "/index.html"
- }
- });
- gulp.watch(['./css/*.scss','./css/styles.css']).on('change', gulp.series(mixin, build));
- gulp.watch('./js/scripts.js', gulp.series(build));
- gulp.watch('./*.html', reload);
- gulp.watch([
- './css/site.css',
- './js/site.js'
- ]).on('change',browserSync.reload);
- console.log("๐ฅ Run");
- }
- exports.copy = copy;
- exports.build = build;
- exports.purge = purge;
- exports.clean = clean;
- exports.mixin = mixin;
- exports.run = run;
-
|