-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
38 lines (32 loc) · 995 Bytes
/
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
const path = require('path')
const gulp = require('gulp')
const del = require('del')
const browserSync = require('browser-sync').create()
const compileDirectory = require('dovetailer')
const config = require('./config')
const clean = () => del([config.DIRS.BUILD, config.DIRS.CACHE])
const compile = async filePath => {
const templatePath = filePath ? path.parse(filePath).dir : config.DIRS.EMAILS
await compileDirectory(templatePath, {
doctype: config.options.doctype
})
}
const compileAll = () => compile()
const startServer = cb => {
browserSync.init(
{
server: {
baseDir: config.DIRS.BUILD,
directory: true
},
ui: false
},
cb
)
}
const watch = () => {
gulp.watch(config.FILES.EMAILS).on('change', compile)
gulp.watch([config.FILES.COMPONENTS, config.FILES.TEMPLATES], compileAll)
gulp.watch(config.FILES.BUILD).on('change', browserSync.reload)
}
gulp.task('default', gulp.series(clean, compileAll, startServer, watch))