-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
39 lines (32 loc) · 959 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
const gulp = require('gulp');
const ts = require('gulp-typescript');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const tsCJSProject = ts.createProject('tsconfig.json');
const tsESMProject = ts.createProject('tsconfig.esm.json');
/**
* @param {compile.Project} tsProject
* @param {boolean} minify
* @param {string} dist
*/
function build(tsProject, minify, dist) {
return function(done){
"use strict";
var t = gulp.src("src/**/*.ts")
.pipe(tsProject());
t.js.pipe(gulp.dest(dist));
if (minify) {
t.js.pipe(uglify())
.pipe(rename({extname:'.min.js'}))
}
t.js.pipe(gulp.dest(dist));
t.dts.pipe(gulp.dest(dist));
done();
}
}
gulp.task('build:cjs', build(tsCJSProject, true, 'dist'));
gulp.task('build:esm', build(tsESMProject, false, 'dist/esm'));
gulp.task('watch', function() {
gulp.watch("src/**/*.ts", gulp.series('build'));
});
gulp.task('default', gulp.series('build:cjs','watch'));