-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
55 lines (46 loc) · 1.33 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
var gulp = require('gulp');
var spawn = require('child_process').spawn;
var postcss = require('gulp-postcss');
var cssnext = require('postcss-cssnext');
var cssnano = require('cssnano');
var atImport = require("postcss-import")
var http = require('http');
var serveStatic = require('serve-static');
var finalhandler = require('finalhandler');
var options = {
'port': 8000,
'host': 'localhost',
'cssSrcPath': './css/src/',
'cssDistPath': './_includes/'
};
gulp.task('server', function () {
var serve = serveStatic('./_site');
var server = http.createServer(function(req, res){
var done = finalhandler(req, res)
serve(req, res, done)
});
server.listen(options.port);
});
gulp.task('css', function () {
gulp.src(options.cssSrcPath + 'main.css')
.pipe(postcss([atImport, cssnext, cssnano]))
.pipe(gulp.dest(options.cssDistPath));
});
gulp.task('jekyll', function () {
spawn('bundle', ['exec', 'jekyll', 'build'], {
stdio: 'inherit'
});
gulp.src(['_site/**/*.html', '_site/**/*.md']);
})
gulp.task('watch', function() {
gulp.watch(options.cssSrcPath + '**/*.css', ['css']);
gulp.watch([
'./_includes/main.css',
'./**/*.html',
'./**/*.md',
'!./_site/**/*',
'!./node_modules/**/*'
], ['jekyll']);
});
gulp.task('build', ['css', 'jekyll']);
gulp.task('default', ['server', 'build', 'watch']);