-
Notifications
You must be signed in to change notification settings - Fork 7
/
gulpfile.js
57 lines (49 loc) · 1.09 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
'use strict';
const browserSync = require('browser-sync').create();
const del = require('del');
const env = require('gulp-util').env;
const gulp = require('gulp');
const handlebars = require('gulp-compile-handlebars');
const rename = require('gulp-rename');
const config = {
src: './src',
dest: './dist',
watchers: [
{
match: ['./src/**/*.hbs'],
tasks: ['html']
}
]
};
gulp.task('clean', () => del(config.dest));
gulp.task('html', ['clean'], () => {
return gulp.src(`${config.src}/pages/*.hbs`)
.pipe(handlebars({}, {
ignorePartials: true,
batch: [`${config.src}/partials`]
}))
.pipe(rename({
extname: '.html'
}))
.pipe(gulp.dest(config.dest));
});
gulp.task('serve', () => {
browserSync.init({
open: false,
notify: false,
files: [`${config.dest}/**/*`],
server: config.dest
});
});
gulp.task('watch', () => {
config.watchers.forEach(item => {
gulp.watch(item.match, item.tasks);
});
});
gulp.task('default', ['html'], done => {
if (env.dev) {
gulp.start('serve');
gulp.start('watch');
}
done();
});