-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
62 lines (58 loc) · 1.46 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
54
55
56
57
58
59
60
61
62
const gulp = require('gulp')
const uglify = require('gulp-uglify')
const babel = require('gulp-babel')
const rename = require('gulp-rename')
const ts = require('gulp-typescript')
const pack = require('./package.json')
const tsconfig = require('./tsconfig.json')
gulp.task('build_common', function () {
return gulp.src(['index.ts'])
.pipe(ts(tsconfig.compilerOptions))
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(rename({
basename: 'index',
extname: '.common.js'
}))
.pipe(gulp.dest('dist'))
})
gulp.task('build_esm', function () {
return gulp.src(['index.ts'])
.pipe(ts({
strict: true,
moduleResolution: 'node',
noImplicitAny: true,
target: 'es5',
module: 'esnext',
lib: ['dom', 'esnext']
}))
.pipe(rename({
basename: 'index',
extname: '.esm.js'
}))
.pipe(gulp.dest('es'))
})
gulp.task('build_umd', function () {
return gulp.src(['index.ts'])
.pipe(ts(tsconfig.compilerOptions))
.pipe(babel({
moduleId: pack.name,
presets: ['@babel/env'],
plugins: ['@babel/transform-modules-umd']
}))
.pipe(rename({
basename: 'index',
suffix: '.umd',
extname: '.js'
}))
.pipe(gulp.dest('dist'))
.pipe(uglify())
.pipe(rename({
basename: 'index',
suffix: '.umd.min',
extname: '.js'
}))
.pipe(gulp.dest('dist'))
})
gulp.task('build', gulp.parallel('build_common','build_esm', 'build_umd'))