-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
83 lines (71 loc) · 2.38 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
83
var gulp = require('gulp');
var cp = require('child_process');
var minifyCss = require('gulp-minify-css');
var notify = require("gulp-notify")
var sass = require('gulp-ruby-sass')
;
var bower = require('gulp-bower');
var browserSync = require('browser-sync');
var imagemin = require('gulp-imagemin');
var config = {
sassPath: './_sass',
bowerDir: './bower_components',
assetDir: './assets',
outputDir: './_site'
}
var messages = {
jekyllBuild: '<span style="color: grey">Running:</span> $ jekyll build'
};
gulp.task('bower', function() {
return bower()
.pipe(gulp.dest(config.bowerDir))
});
gulp.task('jekyll-build', ['css','icons','bower'], function (done) {
browserSync.notify(messages.jekyllBuild);
return cp.spawn('jekyll', ['build'], {stdio: 'inherit'})
.on('close', done);
});
gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
browserSync.reload();
});
// minifiy images
gulp.task('images', function () {
return gulp.src('images/*')
.pipe(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}))
.pipe(gulp.dest('images'));
});
gulp.task('icons', function() {
return gulp.src(config.bowerDir + '/fontawesome/fonts/**.*')
.pipe(gulp.dest(config.assetDir + '/fonts'))
.pipe(gulp.dest(config.outputDir + '/assets/fonts'));
});
gulp.task('css', function() {
return sass(config.sassPath + '/main.scss', {
style: 'compressed',
loadPath: [
config.sassPath,
config.bowerDir + '/normalize.scss/',
config.bowerDir + '/fontawesome/scss',
],
compass: true
})
.pipe(minifyCss())
.pipe(gulp.dest(config.assetDir + '/css'))
.pipe(gulp.dest(config.outputDir + '/assets/css'))
.pipe(browserSync.stream());
});
gulp.task('build', ['bower', 'icons', 'css' ,'jekyll-build']);
gulp.task('serve', ['build'], function() {
browserSync.init({
server: {
baseDir: "./_site"
}
});
// Start a watch for rebuilds
gulp.watch(['_sass/*.scss'], ['css'])
gulp.watch(['index.html', '_layouts/*.html', '_includes/*', '_posts/*', 'images/*'], ['jekyll-rebuild']);
});
gulp.task('default', ['serve']);