-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
55 lines (45 loc) · 1.16 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
const gulp = require('gulp')
const del = require('del')
const eslint = require('gulp-eslint')
const gulpless = require('gulp-less')
const browserSync = require('browser-sync').create()
const lintFiles = ['*.js']
const lessFiles = ['*.less']
const clean = () => del('generated/*.html')
const less = () =>
gulp.src(lessFiles)
.pipe(gulpless())
.pipe(gulp.dest('generated'))
.pipe(browserSync.stream())
const buildTask = (done) => {
delete require.cache[require.resolve('./build')]
require('./build')()
browserSync.reload()
done()
}
const build = gulp.series(gulp.parallel(clean, less), buildTask)
const watchless = gulp.series(less, () => {
gulp.watch(lessFiles, less)
})
const lint = () =>
gulp.src(lintFiles)
.pipe(eslint())
.pipe(eslint.format())
const watch = gulp.series(build, () => {
process.env.NODE_DEV = 'development'
gulp.watch(lintFiles, gulp.series(lint, build))
gulp.watch(['partials/*', 'bookdata/*'], build)
})
const browsersync = () => {
browserSync.init({
open: false,
server: {
baseDir: "./generated/"
}
})
}
module.exports = {
build,
lint,
default: gulp.parallel(watch, watchless, browsersync)
}