-
Notifications
You must be signed in to change notification settings - Fork 8
/
gulpfile.js
77 lines (67 loc) · 2 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
var gulp = require('gulp');
var less = require('gulp-less');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var babel = require('gulp-babel');
var plumber = require('gulp-plumber');
var cp = require('child_process');
var util = require('util');
var beep = require('beepbeep');
gulp.task('styles', function () {
return gulp.src('less/main.less')
.pipe(plumber(function () {
beep();
console.error('Error compiling less.');
this.emit('end');
}))
.pipe(less())
.pipe(gulp.dest('_site/css'));
});
gulp.task('js', function () {
return gulp.src(['js/**/*.js', '!js/vendor/**/*.js'])
.pipe(plumber(function () {
beep();
console.error('Error compiling JS.');
this.emit('end');
}))
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'))
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest('_site/js'));
});
gulp.task('copy:js', function () {
return gulp.src([
'bower_components/jquery/dist/jquery.min.js',
'bower_components/semantic/dist/semantic.min.js',
'bower_components/requirejs/require.js',
'js/vendor/**/*.js'
]).pipe(gulp.dest('_site/js'))
});
gulp.task('copy:fonts', function () {
return gulp.src([
'bower_components/semantic/dist/themes/default/**/*'
]).pipe(gulp.dest('_site/css/themes/default'));
});
gulp.task('copy', ['copy:js', 'copy:fonts']);
gulp.task('jekyll', ['build'], function () {
var jekyll = cp.spawn('jekyll', ['serve', '--host=0.0.0.0', '--config=' + __dirname + '/_config.yml'], {stdio: 'inherit'})
.on('error', (error) => {
console.error(util.inspect(error));
process.exit(1);
})
.on('close', console.log.bind(console));
process.on('exit', () => {
jekyll.stdin.pause();
jekyll.kill();
});
return jekyll;
});
gulp.task('build', ['styles', 'js', 'copy']);
gulp.task('default', ['jekyll', 'watch']);
gulp.task('watch', function () {
gulp.watch('js/*', ['js']);
gulp.watch('less/*', ['styles']);
});