-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
112 lines (95 loc) · 2.81 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
var gulp = require('gulp');
var browserSync = require('browser-sync');
var cp = require('child_process');
var $ = require('gulp-load-plugins')();
var config = {
dest: '_site',
assetsFolder: 'assets',
messages: '<span style="color: grey">Running:</span> $ jekyll build'
};
/**
* Build the Jekyll Site
*/
gulp.task('jekyll-build', function (cb) {
browserSync.notify(config.messages);
return cp.spawn('jekyll', ['build'], {stdio: 'inherit'})
.on('close', cb);
});
/**
* Rebuild Jekyll & do page reload
*/
gulp.task('jekyll-rebuild', ['styles', 'jekyll-build'], function (cb) {
browserSync.reload();
});
/**
* Wait for jekyll-build, then launch the Server
*/
gulp.task('browser-sync', ['styles', 'jekyll-build'], function() {
browserSync({
server: {
baseDir: config.dest
}
});
});
// SVG Icons
gulp.task('svg', ['svg-kss'], function () {
return gulp.src(config.assetsFolder + '/_svg/*.svg')
.pipe($.svgSprites({
preview: false, // no preview
mode: 'symbols' // output SVG data
}))
.pipe(gulp.dest(config.assetsFolder));
});
// SVG Icons With Preview - styleguide
gulp.task('svg-kss', function () {
return gulp.src(config.assetsFolder + '/_svg/*.svg')
.pipe($.svgSprites({
mode: 'symbols'
}))
.pipe(gulp.dest(config.dest + '/styleguide'));
});
/**
* inject bower components
*/
var wiredep = require('wiredep').stream;
gulp.task('wiredep', function () {
// includes dependencies in jekyll include folder
// until we find the way to make it
gulp.src('_includes/*.html')
.pipe(wiredep({
ignorePath: '..'
}))
.pipe(gulp.dest('_includes'));
// template-kss
// Also includes the same dependencies in the styleguide main file.
gulp.src('_template-kss/index.html')
.pipe(wiredep())
.pipe(gulp.dest('_template-kss/'));
});
/**
* Compile files from _scss into both _site/css (for live injecting) and site (for future jekyll builds)
*/
gulp.task('styles', function () {
return gulp.src(config.assetsFolder + '/_scss/*.scss')
.pipe($.rubySass({
require: ['bootstrap-sass']
}))
.pipe($.autoprefixer(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
.pipe(gulp.dest(config.dest + '/'+ config.assetsFolder + '/css'))
.pipe(browserSync.reload({stream:true}));
});
/**
* Watch scss files for changes & recompile
*/
gulp.task('watch', function () {
gulp.watch(config.assetsFolder + '/_scss/**/*.scss', ['styles']);
gulp.watch(['index.html', config.assetsFolder + '/js/**/*', 'pages/**/*.html', '_layouts/*.html', '_includes/**/*.html'], ['jekyll-rebuild']);
});
/**
* Default task,
* running just `gulp` will
* wireup bower dependecies,
* compile the sass,
*/
gulp.task('serve', ['browser-sync', 'watch']);
gulp.task('default', ['serve']);