-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
70 lines (63 loc) · 1.72 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
const gulp = require('gulp');
const cp = require('child_process');
const bs = require('browser-sync');
const postcss = require('gulp-postcss');
const cssImport = require('postcss-import');
const nest = require('postcss-nested');
const customProps = require('postcss-custom-properties');
const calc = require('postcss-calc');
const nano = require('gulp-cssnano');
// Build jekyll project
gulp.task('jekyll', done => {
cp.spawn('jekyll', ['build', '--drafts', '--quiet', '--future'], { stdio: 'inherit' }).on('close', done);
});
// Rebuild and refresh project
gulp.task('reload', ['jekyll'], () => {
bs.reload();
});
// Start BrowserSync server and serve _site directory
gulp.task('browser-sync', ['styles', 'jekyll'], () => {
bs({
ui: false,
ghostMode: {
clicks: true,
forms: false,
scroll: true
},
logPrefix: 'songroger',
notify: false,
// port: 4000,
server: {
baseDir: '_site'
}
});
});
// Process css, autoprefix, minify
gulp.task('styles', () => {
const processors = [
cssImport,
customProps,
calc,
nest
];
return gulp.src('_src/css/main.css')
.pipe(postcss(processors))
.pipe(nano({
//the following option is for :CSS3 Animation is missing after minify
reduceIdents: {
keyframes: false
},
discardUnused: {
keyframes: false
}
})
)
.pipe(gulp.dest('_includes/css'));
});
// Watch sass and all html posts
gulp.task('watch', () => {
gulp.watch('_src/css/**/*.css', ['styles', 'reload']);
gulp.watch(['index.html', '_layouts/*.html', '_includes/*.html', '_posts/*', '_drafts/*', '*.md'], ['reload']);
});
// default task
gulp.task('default', ['styles', 'watch']);