-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
36 lines (30 loc) · 1.02 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
const gulp = require("gulp");
const ts = require("gulp-typescript");
const sourcemaps = require('gulp-sourcemaps');
const watch = require('gulp-watch');
const del = require('del');
const tsProject = ts.createProject("tsconfig.json");
function compile() {
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.pipe(sourcemaps.mapSources((sourcePath, file) => {
const depth = sourcePath.match(new RegExp("\/", "g")).length - 2;
const after = new Array(depth).fill('../').concat() + sourcePath;
console.log(sourcePath, '=====>', after);
return after;
}))
.pipe(sourcemaps.write('map'))
.pipe(gulp.dest("dist"));
}
function cleanUp() {
return del([
'dist/**/*'
]);
}
function watchify() {
// Callback mode, useful if any plugin in the pipeline depends on the `end`/`flush` event
return watch('src/**/*.ts', gulp.series([cleanUp, compile]));
}
gulp.task(compile);
gulp.task('default', gulp.series(watchify));