-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
64 lines (52 loc) · 1.66 KB
/
gulpfile.js
File metadata and controls
64 lines (52 loc) · 1.66 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
const gulp = require('gulp');
const concat = require('gulp-concat');
const cleancss = require('gulp-minify-css');
const child = require('child_process');
const sass = require('gulp-sass');
const gutil = require('gulp-util');
var paths = require('./_app/gulp/paths');
gulp.task('css', () => {
gulp.src(paths.appSassFilesGlob)
.pipe(sass())
.pipe(concat('main.css'))
.pipe(cleancss({advanced:false}))
.pipe(gulp.dest(paths.jekyllStyleFiles))
});
gulp.task('jekyll', () => {
const jekyll = child.spawn('bundle', ['exec', 'jekyll', 'build',
'--config',
'_config.yml,_app/localhost_config.yml'
]);
const jekyllLogger = (buffer) => {
buffer.toString()
.split(/\n/)
.forEach((message) => gutil.log('Jekyll: ' + message));
};
jekyll.stdout.on('data', jekyllLogger);
});
const browserSync = require('browser-sync').create();
const siteRoot = '_site';
gulp.task('serve', () => {
browserSync.init({
open: false,
files: [siteRoot + '/**'],
host: "0.0.0.0",
port: 4000,
server: {
baseDir: siteRoot
}
});
// Watch for app style files
gulp.watch(paths.appSassFilesGlob, ['css']);
// Watch for config files
gulp.watch(['_config.yml', '_app/localhost_config.yml'], ['jekyll']);
// Watch for .html files
gulp.watch(['**/*.html', '!_site/**/*.*'], ['jekyll']);
// Watch for md files
gulp.watch(['**/'+paths.markdownPattern, '!_site/**/*.*'], ['jekyll']);
// Watch for data files
gulp.watch(['_data/*.yml'], ['jekyll']);
// Watch for assets
gulp.watch(['assets/img/'+paths.imagePattern, 'assets/main.css'], ['jekyll']);
});
gulp.task('default', ['css', 'jekyll', 'serve']);