-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
60 lines (53 loc) · 1.8 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
var gulp = require('gulp');
var util = require('util');
var postcss = require('gulp-postcss');
var cssnext = require('postcss-cssnext');
var nano = require('gulp-cssnano');
var shell = require('gulp-shell');
var autoprefixer = require('gulp-autoprefixer');
var atImport = require('postcss-import');
var cp = require('child_process');
var browserSync = require('browser-sync').create();
var htmlmin = require('gulp-html-minifier');
var processors = [
atImport,
cssnext({
'browsers': ['last 2 version'],
'features': {
'customProperties': {
preserve: true,
appendVariables: true
},
'colorFunction': true,
'customSelectors': true,
'sourcemap': true,
'rem': false
}
})
];
gulp.task('styles', function() {
return gulp.src(['./_assets/src/style.css', './_assets/src/frontpage.css'])
.pipe(postcss(processors))
.pipe(nano({discardComments: {removeAll: true}}))
.pipe(gulp.dest('./_assets/css'));
});
gulp.task('buildSite', shell.task('bundle exec jekyll build --incremental'));
gulp.task('minify', ['buildSite'], function() {
return gulp.src('_site/**/*.html')
.pipe(htmlmin({
collapseWhiteSpace: true,
removeTagWhitespace: true,
lint: true,
minifyJS: true
}))
.pipe(gulp.dest('_site'));
});
gulp.task('jekyll-build', shell.task(['bundle exec jekyll build --incremental --watch']));
gulp.task('jekyll-build-once', ['buildSite', 'minify']);
gulp.task('jekyll-serve', function() {
browserSync.init({ server: { baseDir: '_site/' } });
gulp.watch('./_assets/src/*.css', ['styles']);
gulp.watch('_site/**/*.*').on('change', browserSync.reload);
});
gulp.task('default', ['jekyll-build', 'jekyll-serve', 'styles']);
gulp.task('build', ['styles', 'jekyll-build-once']);