-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
65 lines (57 loc) · 1.76 KB
/
gulpfile.js
File metadata and controls
65 lines (57 loc) · 1.76 KB
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
var gulp = require('gulp'),
cp = require('child_process'),
browserSync = require('browser-sync'),
plugins = require('gulp-load-plugins')();
// Build the Jekyll Site
gulp.task('jekyll-build', function (done) {
return cp.spawn('jekyll', ['build'], { stdio: 'inherit' })
.on('close', done);
});
// Rebuild Jekyll & do page reload when changes happen
gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
browserSync.reload();
});
// Wait for jekyll-build, then launch the browser-sync server
gulp.task('browser-sync', ['build', 'jekyll-build'], function() {
browserSync({
server: {
baseDir: '_site'
}
});
});
// Build task
gulp.task('build', ['styles']);
// Styles task
gulp.task('styles', function() {
gulp.src('sass/**/*.scss')
.pipe(plugins.sass({
errLogToConsole: true,
onError: browserSync.notify
}))
.pipe(plugins.autoprefixer({
browsers: ['> 1%','last 4 versions'],
cascade: false
}))
.pipe(plugins.minifyCss())
.pipe(gulp.dest('_site/stylesheets/'))
.pipe(browserSync.reload({stream:true}))
.pipe(gulp.dest('./stylesheets/'));
});
// Image task
gulp.task('images', function() {
gulp.src('images/**/*')
.pipe(plugins.imagemin({
svgoPlugins: [{removeViewBox: false}]
}))
.pipe(gulp.dest('_site/images'))
.pipe(browserSync.reload({ stream: true }))
.pipe(gulp.dest('./images'));
})
// Watch task
gulp.task('watch', function () {
gulp.watch('sass/**/*.scss',['styles']);
gulp.watch('images/**/*',['images']);
gulp.watch(['**/*.html', '_config.yml'], ['jekyll-rebuild']);
});
// Default task
gulp.task('default', ['browser-sync', 'watch']);