-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
102 lines (84 loc) · 2.15 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
94
95
96
97
98
99
100
101
102
const gulp = require('gulp');
const tsc = require('gulp-tsc');
const shell = require('gulp-shell');
const tslint = require('gulp-tslint');
const babel = require('gulp-babel');
const paths = {
tscripts: { src: ['src/**/*.ts'], dest: 'build' },
jsscripts: { src: ['src/**/*.js'], dest: 'build' },
staticFiles: { src: ['src/templates/**/*'], dest: 'build/templates' },
staticAssets: { src: ['src/static/**/*'], dest: 'build/static' }
};
function defaultTask(cb) {
gulp.series('lint', buildrunTask)(cb);
}
// ** Running ** //
function runTask(cb) {
shell.task([
'node build/index.js'
])();
cb();
}
function buildrunTask(cb) {
gulp.series('build', runTask)(cb);
}
// ** Watching ** //
function watchTask() {
gulp.watch(paths.tscripts.src, compileTask);
}
function watchrunTask() {
gulp.watch(paths.tscripts.src, gulp.series(compileTask, runTask));
}
// ** Compilation ** //
function buildTask(cb) {
gulp.series(compileTypescriptTask, compileJavascriptTask, copyStaticTask)(cb);
}
function compileTask(cb) {
gulp.series(compileTypescriptTask, compileJavascriptTask, copyStaticTask)(cb);
}
function compileTypescriptTask() {
return gulp
.src(paths.tscripts.src)
.pipe(tsc({
module: "commonjs",
emitError: false
}))
.pipe(gulp.dest(paths.tscripts.dest));
}
function compileJavascriptTask() {
return gulp
.src(paths.jsscripts.src)
.pipe(babel())
.pipe(gulp.dest(paths.jsscripts.dest));
}
function copyStaticTask(cb) {
return gulp.parallel(
copyStaticFiles,
copyStaticAssets
)(cb);
}
function copyStaticFiles() {
return gulp
.src(paths.staticFiles.src)
.pipe(gulp.dest(paths.staticFiles.dest));
}
function copyStaticAssets() {
return gulp
.src(paths.staticAssets.src)
.pipe(gulp.dest(paths.staticAssets.dest));
}
// ** Linting ** //
function lintTask() {
return gulp.src(paths.tscripts.src)
.pipe(tslint())
.pipe(tslint.report('prose', {
emitError: false
}));
}
exports.default = defaultTask;
exports.lint = lintTask;
exports.compile = compileTask;
exports.build = buildTask;
exports.buildrun = buildrunTask;
exports.watch = watchTask;
exports.watchrun = watchrunTask;