-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.ts
56 lines (51 loc) · 1.33 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* gulpfile.ts
*/
import gulp from 'gulp';
import uglify from 'gulp-uglify';
import tsc from 'gulp-typescript';
import sourcemaps from 'gulp-sourcemaps';
import concat from 'gulp-concat';
import browserify from 'browserify';
import tsify from 'tsify';
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
// build and minify library
gulp.task('build:lib', () => {
return browserify({
basedir: '.',
debug: true,
entries: './lib/index.ts',
cache: {},
packageCache: {},
standalone: 'randimals',
})
.plugin(tsify)
.bundle()
.pipe(source('index.js'))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist'));
});
// build and minify cli tool
gulp.task('build:cli', () => {
return gulp.src('./lib/cli.ts').pipe(tsc()).pipe(gulp.dest('./bin'));
});
// build types
gulp.task('build:types', () => {
return gulp
.src([
'./lib/types.ts',
'./lib/index.ts',
'./lib/formatter.ts',
'./lib/random.ts',
])
.pipe(tsc({ declaration: true }))
.dts.pipe(concat('index.d.ts'))
.pipe(gulp.dest('./dist'));
});
// build both library and cli tool
gulp.task('build', gulp.parallel(['build:lib', 'build:cli', 'build:types']));
gulp.task('default', gulp.series('build'));