-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
68 lines (53 loc) · 1.69 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
const fs = require('fs');
const gulp = require('gulp');
const flatten = require('gulp-flatten')
var build = 'html';
var json = './src/json/'
// Main Build tasks
gulp.task('pug', function() {
const pug = require('gulp-pug');
const data = require('gulp-data');
const locals = require('./src/locals.js');
gulp.src(['src/views/*/*.pug', '!src/views/_includes/**'])
.pipe(pug({locals: locals}))
.on('error', console.log)
.pipe(flatten())
.pipe(gulp.dest(build));
});
gulp.task('sass', function() {
const sass = require('gulp-sass');
const paths = ['src/public/'];
gulp.src(['src/views/*/*.sass', 'src/public/*.sass'])
.pipe(sass({includePaths: paths})
.on('error', sass.logError))
.pipe(flatten())
.pipe(gulp.dest(build + '/css'));
});
// Resource tasks
gulp.task('js', function() {
gulp.src('src/views/**/*.js')
.pipe(flatten())
.pipe(gulp.dest(build + '/js'));
});
gulp.task('assets', function() {
gulp.src('src/public/assets/**/*')
.pipe(gulp.dest(build + '/public/'));
gulp.src('src/public/favicon/*')
.pipe(gulp.dest(build));
});
// Utility tasks
gulp.task('clean', function() {
var clean = require('gulp-clean');
gulp.src('html/**/*', {read:false})
.pipe(clean());
});
gulp.task('watch', ['build'], function() {
gulp.watch('src/views/**/*.pug', ['pug']);
gulp.watch('src/**/*.sass', ['sass']);
gulp.watch('src/views/**/*.js', ['js']);
gulp.watch('src/public/**', ['assets']);
gulp.watch('src/locals.js', ['pug'])
});
gulp.task('views', ['pug', 'sass']);
gulp.task('build', ['views', 'assets', 'js']);
gulp.task('default', ['build']);