1
0
mirror of https://github.com/Mayccoll/Gogh.git synced 2023-08-10 21:12:46 +03:00
Gogh/gulpfile.js

63 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-03-06 07:29:02 +03:00
/* global $, fetch, console */
/* eslint no-undef: "error", semi: 2 */
'use strict';
const {
src,
dest,
parallel,
series,
watch
} = require('gulp');
const htmlmin = require('gulp-htmlmin');
2020-03-06 07:29:02 +03:00
const inlinesource = require('gulp-inline-source');
const rename = require('gulp-rename');
const browserSync = require('browser-sync').create();
const sass = require('gulp-sass');
2020-03-06 07:29:02 +03:00
function sassCompile () {
return src('./gh-pages/sass/**/main.scss')
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(rename('main.min.css'))
.pipe(dest('./gh-pages/css'));
}
function minify () {
return src('./gh-pages/*.src.html')
.pipe(inlinesource())
.pipe(htmlmin({
collapseWhitespace: true
}))
.pipe(rename('index.html'))
.pipe(dest('./gh-pages/'));
}
function serve () {
browserSync.init({
port: 8890,
reloadDelay: 500,
ui: false,
open: true,
server: {
baseDir: './',
directory: true
}
});
}
function reload (done) {
browserSync.reload();
done();
}
function watchFiles () {
watch(['./gh-pages/**/*.html', '!./gh-pages/index.html'], series(sassCompile, minify, reload));
watch(['./gh-pages/js/**/*.js'], series(sassCompile, minify, reload));
watch(['./gh-pages/sass/**/*.scss'], series(sassCompile, minify, reload));
}
exports.default = parallel(serve, watchFiles);
exports.dev = parallel(serve, watchFiles);