-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathgulpfile.js
72 lines (60 loc) · 1.67 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
const gulp = require('gulp');
const sass = require('gulp-sass');
const gutil = require('gulp-util');
const child = require('child_process');
const browserSync = require('browser-sync').create();
const prefix = require('gulp-autoprefixer');
const siteRoot = 'docs/';
// Serve static files and auto reload on CSS change
gulp.task('serve', () => {
browserSync.init({
files: [siteRoot + '/**'],
port: 4010,
proxy: 'localhost:4000'
});
gulp.watch('./_sass/**.scss', ['sass']);
});
// Start Jekyll
gulp.task('jekyll', () => {
const jekyll = child.spawn('jekyll', [
'serve',
'--watch',
'--host=0.0.0.0',
'--incremental',
'--drafts'
]);
const jekyllLogger = (buffer) => {
buffer.toString()
.split(/\n/)
.forEach((message) => gutil.log('Jekyll: ' + message));
};
jekyll.stdout.on('data', jekyllLogger);
jekyll.stderr.on('data', jekyllLogger);
});
// Transpile scss
gulp.task('sass', function () {
return gulp.src('./_sass/main.scss')
.pipe(prefix())
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./docs/css'));
});
gulp.task('jekyll-build', (cb) => {
const jekyll = child.spawn('jekyll', [
'build'
]);
const jekyllLogger = (buffer) => {
buffer.toString()
.split(/\n/)
.forEach((message) => gutil.log('Jekyll: ' + message));
};
jekyll.on('exit', cb)
jekyll.stdout.on('data', jekyllLogger);
jekyll.stderr.on('data', jekyllLogger);
});
gulp.task('dist', ['jekyll-build'], function () {
return gulp.src('./_sass/main.scss')
.pipe(prefix())
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./docs/css'));
});
gulp.task('default', ['sass', 'jekyll', 'serve']);