-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
52 lines (45 loc) · 1.34 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
const gulp = require("gulp");
const del = require("del");
const vinylPaths = require("vinyl-paths");
const runSequence = require("run-sequence");
const ts = require("gulp-typescript");
const to5 = require("gulp-babel");
const replace = require("gulp-replace");
const tsProject = ts.createProject("tsconfig.json", {
typescript: require("typescript")
});
const outputPath = "dist/";
const dtsFile = outputPath + "uploader.d.ts";
gulp.task("clean", function() {
return gulp.src([outputPath])
.pipe(vinylPaths(del));
});
gulp.task("build-dts", function() {
return require("dts-generator").default({
name: "uploader",
baseDir: "./src",
files: ["index.ts"],
out: dtsFile
});
});
gulp.task("dts-fix", function() {
return gulp.src(dtsFile)
.pipe(replace("declare module 'uploader/index'", "declare module 'uploader'"))
.pipe(gulp.dest(outputPath));
});
gulp.task('build-common', function() {
return gulp.src(["src/**/*.ts", "typings/**/*.d.ts"])
.pipe(ts(tsProject))
.pipe(to5({
modules: "common"
}))
.pipe(gulp.dest(outputPath));
});
gulp.task('build', function(callback) {
return runSequence(
'clean',
'build-common',
'build-dts',
'dts-fix',
callback);
});