forked from KoreaHTML5/webframeworks.kr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
83 lines (70 loc) · 2.05 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
/**
* Korea HTML5
* Copyright 2014 Korea HTML5
*/
var gulp = require('gulp');
var exec = require('child_process').exec;
var del = require('del');
var deploy = require("gulp-gh-pages");
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var runSequence = require('run-sequence');
// Jekyll task, build with jekyll
gulp.task('jekyll-gh', function(cb){
return exec('jekyll build --config _config.yml,_config_gh.yml', function(error, stdout, stderr){
console.log(stdout);
cb();
});
});
gulp.task('jekyll', function(cb){
return exec('jekyll build --config _config.yml', function(error, stdout, stderr){
console.log(stdout);
cb();
});
});
// Github io page task, makes github.io page version
gulp.task('gh', function () {
runSequence('clean', 'jekyll-gh', 'cname', 'publish');
});
gulp.task('cname', function(){
return gulp.src('CNAME')
.pipe(gulp.dest('publish/'))
});
gulp.task('publish', function(){
return gulp.src('publish/**/*')
.pipe(deploy({
remoteUrl: 'https://github.com/KoreaHTML5/webframeworks.kr.git'
}));
});
// Dist task, make distribution version with node application
gulp.task('dist', ['default'], function () {
return gulp.src(['publish/**/*'], {base: '.'})
.pipe(gulp.dest('dist'))
});
// Watch files changes
gulp.task('watch', function() {
gulp.watch(['contents/**/*.html', 'contents/**/*.css', 'contents/**/*.js'], ['jekyll', reload]);
gulp.watch(['contents/getstarted/**/*.md'], ['jekyll', reload]);
gulp.watch(['contents/tutorials/**/*.md'], ['jekyll', reload]);
gulp.watch(['contents/quickstart/**/*.md'], ['jekyll', reload]);
});
// Browser-sync for preview
gulp.task('browser-sync', function() {
browserSync.init(null, {
notify: false,
server: {
baseDir: 'publish'
},
port: 8888
});
});
// Watch files for changes & reload
gulp.task('serve', ['default'], function (cb) {
runSequence('browser-sync', 'watch', cb);
});
// Clean task
gulp.task('clean', del.bind(null, ['publish', 'dist']));
// Default task to build
gulp.task('default', ['clean'], function(cb) {
runSequence('jekyll', cb);
});