-
Notifications
You must be signed in to change notification settings - Fork 13
/
gulpfile.js
42 lines (32 loc) · 895 Bytes
/
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
const gulp = require('gulp');
const ts = require('gulp-typescript');
const merge = require('merge2');
const chalk = require('chalk');
const tsProject = ts.createProject('tsconfig.json');
function copy(cb) {
gulp.src(['src/**/*.png'])
.pipe(gulp.dest('lib'));
cb();
};
function tsc(cb) {
const tsResult = tsProject.src()
.pipe(tsProject());
merge([
tsResult.dts.pipe(gulp.dest('lib')), // 生成.d.ts类型文件
tsResult.js.pipe(gulp.dest('lib'))
]);
cb();
};
function dev() {
gulp.parallel(copy, tsc)();
const watcher = [];
watcher.push(gulp.watch(['src/**/*.ts', 'src/**/*.tsx'], tsc));
watcher.push(gulp.watch(['src/**/*.png'], copy));
watcher.forEach((ele) => {
ele.on('change', (fileName, eventType) => {
console.log(chalk.cyan(`${fileName} changed...`))
});
})
}
exports.dev = dev;
exports.default = gulp.parallel(copy, tsc);