-
Notifications
You must be signed in to change notification settings - Fork 180
/
Copy pathgulpfile.js
93 lines (80 loc) · 1.83 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
84
85
86
87
88
89
90
91
92
93
var gulp = require('gulp'),
pug = require('gulp-pug'),
less = require('gulp-less'),
path = require('path'),
htmlhint = require('gulp-htmlhint');
// SOURCES CONFIG
var source = {
templates: {
app: {
files: ['demo/pug/index.pug'],
watch: ['demo/pug/*.pug']
}
},
styles: {
app: {
main: ['yamm/yamm.less'],
dir: 'yamm',
watch: ['yamm/yamm.less']
}
}
};
// BUILD TARGET CONFIG
var build = {
styles: './yamm',
templates: {
app: './'
}
};
// Error handler
function handleError(err) {
console.log(err.toString());
this.emit('end');
}
//---------------
// TASKS
//---------------
// LESS
gulp.task('yamm', function() {
return gulp
.src(source.styles.app.main)
.pipe(
less({
paths: [source.styles.app.dir]
})
)
.on('error', handleError)
.pipe(gulp.dest(build.styles));
});
// PUG
gulp.task('templates', function() {
return gulp
.src(source.templates.app.files)
.pipe(
pug({
pretty: true
})
)
.on('error', handleError)
.pipe(htmlhint())
.pipe(htmlhint.reporter())
.pipe(gulp.dest(build.templates.app));
});
//---------------
// WATCH
//---------------
// Watch changes
gulp.task('watch:demo', function() {
gulp.watch(source.templates.app.watch, gulp.series('templates'));
});
gulp.task('watch:yamm', function() {
gulp.watch(source.styles.app.watch, gulp.series('yamm'));
});
//---------------
// DEFAULT TASK
//---------------
gulp.task('default', gulp.series('yamm', 'watch:yamm'));
//---------------
// DEMO TASK
//---------------
gulp.task('demo', gulp.series('yamm', 'templates', gulp.parallel('watch:yamm', 'watch:demo')));