-
Notifications
You must be signed in to change notification settings - Fork 143
/
Copy pathgulpfile.js
47 lines (43 loc) · 1.27 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
const gulp = require('gulp');
const browserSync = require('browser-sync');
const jsonSchema = require("gulp-json-schema");
const merge = require('gulp-merge-json');
const ejs = require("gulp-ejs");
const rename = require('gulp-rename');
function checkJsonSchema(done) {
return gulp.src("jsonFiles/*.json")
.pipe(jsonSchema("./schema.json"))
.on('error', done);
}
function checkJsonSchemaAll(done) {
return gulp.src("dist/*.json")
.pipe(jsonSchema("./schemaAll.json"))
.on('error', done);
}
function mergeGulpFiles() {
return gulp.src('jsonFiles/*.json')
.pipe(merge())
.pipe(gulp.dest('./dist'));
}
function browser() {
browserSync.init({
server: { baseDir: './dist/' },
reloadDebounce: 2000
})
}
function parseEjs() {
return gulp.src('source/**.ejs')
.pipe(ejs({ title: 'gulp-ejs' }))
.pipe(rename({ extname: '.html' }))
.pipe(gulp.dest('./dist'))
}
function browserSyncReload(done) {
browserSync.reload();
done();
}
function watch() {
return gulp.watch(['source/*.ejs', 'source/**/*.ejs']).on('change', gulp.series(parseEjs, browserSyncReload));
}
exports.default = gulp.series(checkJsonSchema, mergeGulpFiles, parseEjs, browser, watch)
exports.build = gulp.series(mergeGulpFiles, parseEjs)
exports.check = gulp.parallel(checkJsonSchema)