-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
57 lines (47 loc) · 1.24 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
const gulp = require('gulp');
const ts = require('gulp-typescript');
const sourcemaps = require('gulp-sourcemaps');
const merge = require('merge-stream');
var del = require('del');
const tsProject = ts.createProject('tsconfig.json');
const dirs = {
dist: ['dist']
};
const moveReadme = () => {
return gulp.src('README.md')
.pipe(gulp.dest(dirs.dist))
}
const movePackage = () => {
return gulp.src('package.json')
.pipe(gulp.dest(dirs.dist))
}
const compileProd = () => {
const tsResult = tsProject.src()
.pipe(tsProject())
return merge(tsResult, tsResult.js, tsResult.dts)
.pipe(gulp.dest(dirs.dist));
};
const compileTest = () => {
const tsResult = tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject());
return merge(tsResult, tsResult.js)
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(dirs.dist));
};
const watch = () => {
gulp.watch(['src/**/*.ts', 'index.ts'], buildTest);
};
const delDist = () => {
return del(['dist/**/*']);
};
const buildMeta = gulp.parallel(moveReadme, movePackage)
const build = gulp.series(delDist, compileProd, buildMeta);
const buildTest = gulp.series(compileTest);
const dev = gulp.series(buildTest, watch);
module.exports = {
build,
buildTest,
dev,
default: build
};