-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.ts
28 lines (23 loc) · 927 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
import * as gts from 'gulp-typescript';
import * as sourcemaps from 'gulp-sourcemaps';
const gulp = require('gulp');
const tsCommonjs = gts.createProject('tsconfig.json', { declaration: true, allowJs: false });
const tsModule = gts.createProject('tsconfig.json', { module: 'es2015', target: 'es6' });
function createBuild(type: 'cjs' | 'es') {
gulp.task(`build::${type}`, () => {
return gulp
.src([`src/**/*.ts`, `src/**/*.tsx`])
.pipe(sourcemaps.init())
.pipe(type === 'cjs' ? tsCommonjs() : tsModule())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(`build${type === 'es' ? '/__es_module' : ''}`));
});
}
gulp.task(`copy`, () => {
return gulp
.src(['./package.json', './LICENSE', './README.md'])
.pipe(gulp.dest('build'));
});
createBuild('cjs');
createBuild('es');
gulp.task('default', ['build::cjs', 'build::es', 'copy']);