-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.ts
40 lines (36 loc) · 958 Bytes
/
gulpfile.ts
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
import { task, dest } from "gulp";
import { createProject } from "gulp-typescript";
import rimraf from "rimraf";
import strip from "gulp-strip-comments";
import babel from "gulp-babel";
async function clearLibFolder() {
return new Promise<void>((resolve, reject) => {
rimraf("./lib", (error) => {
if (error) {
return reject(error);
}
resolve();
});
});
}
task("default", async () => {
const tsProject = createProject("tsconfig.json");
await clearLibFolder();
const tsResult = tsProject.src().pipe(tsProject());
const outDir = tsProject.config.compilerOptions.outDir;
tsResult.js
.pipe(strip())
.pipe(
babel({
plugins: [
"@babel/plugin-syntax-nullish-coalescing-operator",
"@babel/plugin-syntax-optional-chaining",
],
}),
)
.pipe(dest(outDir));
return tsResult.dts.pipe(dest(outDir));
});
task("clear", async () => {
clearLibFolder();
});