forked from Gogh-Co/Gogh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (54 loc) · 1.41 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* global $, fetch, console */
/* eslint no-undef: "error", semi: 2 */
/* jshint esversion: 6 */
'use strict';
const {
src,
dest,
parallel,
series,
watch
} = require('gulp');
const htmlmin = require('gulp-htmlmin');
const inlinesource = require('gulp-inline-source');
const rename = require('gulp-rename');
const browserSync = require('browser-sync').create();
const sass = require('gulp-sass');
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);