-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
53 lines (48 loc) · 1.32 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
53
const gulp = require('gulp')
const del = require('del')
const babel = require('gulp-babel')
const rename = require('gulp-rename')
const ts = require('gulp-typescript')
const tsconfig = require('./tsconfig.json')
gulp.task('build_clean', () => {
return del(['dist', 'types'])
})
gulp.task('build_tsc', () => {
return gulp.src('src/**/*.ts')
.pipe(ts({ ...tsconfig.compilerOptions, declaration: true }))
.pipe(gulp.dest('dist/types'))
})
gulp.task('build_js', gulp.series('build_clean', () => {
return gulp.src('src/**/*.ts')
.pipe(ts(tsconfig.compilerOptions))
.pipe(rename({
basename: 'index',
extname: '.mjs'
}))
.pipe(gulp.dest('dist'))
.pipe(babel({
presets: ['@babel/env'],
plugins: [['@babel/plugin-transform-modules-commonjs']]
}))
.pipe(rename({
basename: 'index',
extname: '.cjs'
}))
.pipe(gulp.dest('dist'))
.pipe(babel({
presets: ['@babel/env'],
plugins: [['@babel/transform-modules-umd']]
}))
.pipe(rename({
basename: 'index',
extname: '.js'
}))
.pipe(gulp.dest('dist'))
}))
gulp.task('build_all', gulp.series('build_js', 'build_tsc', () => {
return gulp.src('dist/types/**/*.d.ts')
.pipe(gulp.dest('types'))
}))
gulp.task('build_lazy', gulp.series('build_all', () => {
return del('dist/types')
}))