This repository was archived by the owner on Aug 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
57 lines (49 loc) · 1.75 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
// Write new gulp tasks in this file. Need some help? Check out the gulp.js docs: https://gulpjs.com
// Variables
var gulp = require('gulp');
browserSync = require('browser-sync');
sass = require('gulp-sass');
prefix = require('gulp-autoprefixer');
cp = require('child_process');
reload = require('gulp-reload');
sequence = require('gulp-sequence');
jekyll = process.platform === 'win32' ? 'jekyll.bat' : 'jekyll';
messages = { jekyllBuild: '<span style="color: grey">Running:</span> $ jekyll build' };
// Build the site
gulp.task('build', function (done) {
browserSync.notify(messages.jekyllBuild);
return cp.spawn( jekyll , ['build'], {stdio: 'inherit'})
.on('close', done);
});
// Compile SASS
gulp.task('sass', function () {
return gulp.src('_sass/*.scss')
.pipe(sass())
.pipe(prefix("last 1 version", { cascade: true }))
.pipe(gulp.dest('_site/css'))
.pipe(gulp.dest('css'))
});
// Move assets (fonts, images, etc.) to _site on build
gulp.task('assets', function() {
return gulp.src('_assets/*/*')
.pipe(gulp.dest('_site/assets'))
});
// Start browser-sync
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: '_site'
}
});
});
// Watch certain directories for changes and run sass/jekyll build tasks
gulp.task('watch', function() {
gulp.watch('_sass/*.scss', ['sass']);
gulp.watch(['_includes/*.html', '_layouts/*.html', '*.md', '*.html', '*.yml'], ['rebuild']);
});
// Reload the browser on rebuild
gulp.task('rebuild', ['build'], function () {
browserSync.reload();
});
// Do all of these things when someone runs 'gulp'
gulp.task('default', sequence(['build'], ['sass'], ['assets'], ['browser-sync'], ['watch']));