-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (53 loc) · 1.68 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
var gulp = require('gulp');
var del = require('del');
var spawn = require('child_process').spawn;
var browserSync = require('browser-sync');
var prefix = require('gulp-autoprefixer');
var rev = require('gulp-rev');
var inject = require('gulp-inject');
gulp.task('clean', function(done) {
var manifest = require('./rev-manifest.json');
del(['_site/', 'site.css', 'rev-manifest.json', manifest['site.css']], done);
});
gulp.task('jekyll-build', function(done) {
spawn('jekyll', ['build'], {stdio: 'inherit'})
.on('close', done);
});
gulp.task('jekyll-rebuild', ['jekyll-build'], function() {
browserSync.reload();
});
gulp.task('styles', function() {
return gulp.src('_styles/site.css')
.pipe(prefix())
.pipe(gulp.dest('./_site/'))
.pipe(browserSync.reload({stream: true}))
.pipe(gulp.dest('./')); // So we won't loose it on `jekyll-(re)build`.
});
gulp.task('browser-sync', ['styles', 'jekyll-build'], function() {
browserSync({
server: {
baseDir: '_site'
},
port: 4000
});
});
gulp.task('watch', function() {
gulp.watch(['index.html'], ['jekyll-rebuild']);
gulp.watch(['_styles/site.css'], ['styles']);
});
gulp.task('rev-styles', ['styles'], function() {
return gulp.src('site.css')
.pipe(rev())
.pipe(gulp.dest('.'))
.pipe(rev.manifest())
.pipe(gulp.dest('.'));
});
gulp.task('rev-html', ['rev-styles'], function() {
var manifest = require('./rev-manifest.json');
gulp.src('_site/index.html')
.pipe(inject(gulp.src(manifest['site.css'])))
.pipe(gulp.dest('_site'));
});
gulp.task('build', ['rev-html']);
gulp.task('server', ['browser-sync', 'watch']);
gulp.task('default', ['server']);