-
Notifications
You must be signed in to change notification settings - Fork 17
/
Gulpfile.js
61 lines (49 loc) · 1.29 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
const del = require('del');
const gulp = require('gulp');
const ts = require('gulp-typescript');
const eslint = require('gulp-eslint7');
const terser = require('gulp-terser');
const tsProject = ts.createProject('tsconfig.json');
const paths = {
bin: 'bin',
src: 'src',
typings: 'typings'
};
const terserFiles = {
dest: paths.bin,
src: paths.bin + '/**/*.js'
};
gulp.task('clean', () => del([ paths.bin, paths.typings ]));
gulp.task('lint', () => {
return gulp.src(paths.src + '/**/*.ts')
.pipe(eslint())
.pipe(eslint.formatEach())
.pipe(eslint.failOnError())
});
gulp.task('ts', () => {
const res = tsProject.src()
.pipe(tsProject());
res.js.pipe(gulp.dest(paths.bin));
return res.dts.pipe(gulp.dest(paths.typings));
});
gulp.task('terser', () => {
return gulp.src(terserFiles.src)
.pipe(terser({
toplevel: true,
output: {
beautify: true,
comments: false,
ecma: 8,
indent_level: 2,
max_line_len: 120
}
}))
.pipe(gulp.dest(terserFiles.dest));
});
const commonTasks = [ 'lint', 'clean', 'ts' ];
function watch () {
gulp.watch(paths.src, gulp.series('ts'));
}
gulp.task('default', gulp.series(...commonTasks, 'terser'));
gulp.task('watch', gulp.series(watch));
gulp.task('build', gulp.series(...commonTasks));