-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
83 lines (74 loc) · 1.55 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
71
72
73
74
75
76
77
78
79
80
81
82
83
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var bs = require('browser-sync');
var clean = require('gulp-clean');
var data = require('gulp-data');
var nunj = require('gulp-nunjucks-render');
var sass = require('gulp-sass');
var reload = bs.reload;
var root = './';
var dest = './app';
var css = {
source: './sass/**/*.scss',
out: dest + '/css/',
watch: './sass/**/*.scss',
bundle: 'bundle.min.css'
};
var pages = {
source: './pages/**/*.njk',
out: dest,
watch: './**/*.njk'
};
// Task: Clean build files
gulp.task('clean', function () {
return gulp.src(dest, {
read: false
})
.pipe(clean({
force: true
}))
});
// Compile Nunjucks files
gulp.task('nunj', function () {
var options = {
"indent_size": 2,
"indent_char": " ",
"indent_level": 0,
"preserve_newlines": true,
};
return gulp.src(pages.source)
.pipe(data(function () {
return require('./assets/data/articles.json')
}))
.pipe(nunj({
path: ['templates']
}))
.pipe(gulp.dest(dest))
});
// Compile Our Sass
gulp.task('sass', function () {
return gulp.src(css.source)
.pipe(sass())
.pipe(gulp.dest(css.out))
.pipe(bs.stream());
});
// Browser sync
gulp.task('serve', function () {
bs.init({
server: {
baseDir: root,
index: "./app/index.html"
}
});
gulp.watch(pages.watch, gulp.series('nunj')).on('change', reload);
gulp.watch(css.watch, gulp.series('sass'));
});
// Launch project
gulp.task('default',
gulp.series(
'clean',
'sass',
'nunj',
'serve'
));