This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
executable file
·129 lines (114 loc) · 3.59 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
"use strict";
var gulp = require('gulp');
var browserSync = require('browser-sync');
var uglify = require('gulp-uglify');
var minifyHtml = require('gulp-minify-html');
var minifyCss = require('gulp-minify-css');
var cp = require('child_process');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var args = require('yargs').argv;
var gulpif = require('gulp-if');
var minifyInline = require('gulp-minify-inline-scripts');
var messages = {
jekyllBuild: '<span style="color: grey">Running:</span> $ jekyll build',
cssChanged: '<span style="color: grey">CSS UPDATED:</span>',
jsChanged: '<span style="color: grey">JavaScript UPDATED:</span>'
};
var css_files = [
"src/lib/normalize.css/normalize.css",
"src/lib/font-awesome/css/font-awesome.css",
"src/lib/enjoyhint/enjoyhint.css",
"src/css/grid.css",
"src/css/gisto.css",
"!src/css/style.css"
];
var js_files = [
"src/lib/jquery/dist/jquery.js",
"src/lib/enjoyhint/enjoyhint.min.js",
"src/js/*.js",
"!src/js/script.js"
];
gulp.task('sass', function (done) {
gulp.src('src/css/*.scss')
.pipe(sass())
.pipe(gulp.dest('src/css'));
done();
});
gulp.task('css', gulp.series('sass', function (done) {
browserSync.notify(messages.cssChanged);
return gulp.src(css_files)
.pipe(gulpif(args.min, minifyCss()))
.pipe(concat('style.css'))
.pipe(gulp.dest('_site/css'))
.pipe(browserSync.reload({stream: true}))
.pipe(gulp.dest('src/css'));
done();
}));
gulp.task('js', function () {
browserSync.notify(messages.jsChanged);
return gulp.src(js_files)
.pipe(gulpif(args.min, uglify()))
.pipe(concat('script.js'))
.pipe(gulp.dest('_site/js'))
.pipe(browserSync.reload({stream: true}))
.pipe(gulp.dest('src/js'));
});
gulp.task('html', function () {
var opts = {
comments: false,
spare: true
};
gulp.src('_site/**/*.html')
.pipe(gulpif(args.min, minifyHtml(opts)))
.pipe(gulpif(args.min, minifyInline()))
.pipe(gulp.dest('_site/'));
});
gulp.task('fonts', function () {
return gulp.src([
'src/lib/font-awesome/fonts/**',
'src/lib/enjoyhint/src/Casino_Hand/**'
])
.pipe(gulp.dest('src/fonts'));
});
gulp.task('jekyll-build', gulp.series('fonts', 'css', 'js', function (done) {
browserSync.notify(messages.jekyllBuild);
return cp.spawn('bundle', ['exec', 'jekyll', 'build'], { stdio: 'inherit' }).on('close', done);
}));
gulp.task('jekyll-simple-build', function (done) {
browserSync.notify(messages.jekyllBuild);
return cp.spawn('bundle', ['exec', 'jekyll', 'build'], { stdio: 'inherit' }).on('close', done);
});
gulp.task('jekyll-just-reload', gulp.series('jekyll-simple-build', function (done) {
browserSync.reload();
done();
}));
gulp.task('browser-sync', gulp.series('sass', 'jekyll-build', function (done) {
browserSync.init({
server: {
baseDir: '_site'
}
});
done();
}));
gulp.task('watch', function () {
gulp.watch('src/css/*.scss', gulp.parallel('css'));
gulp.watch('src/js/main.js', gulp.parallel('js'));
gulp.watch('src/index.html', gulp.parallel('jekyll-just-reload'));
gulp.watch('src/_pages/*', gulp.parallel('jekyll-just-reload'));
gulp.watch('src/_includes/*', gulp.parallel('jekyll-just-reload'));
gulp.watch('src/_posts/*', gulp.parallel('jekyll-just-reload'));
});
gulp.task('default', gulp.series('browser-sync', 'watch'));
/**
* Use with `gulp release --min` - will enable all minifications
*/
gulp.task('release', gulp.series('jekyll-build', function() {
gulp.start('html');
// Start browser sync just for preview
browserSync.init({
server: {
baseDir: '_site'
}
});
}));