This repository has been archived by the owner on Mar 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathgulpfile.js
66 lines (57 loc) · 1.92 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
63
64
65
66
/* eslint-disable */
var gulp = require('gulp');
var ts = require('gulp-typescript');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var del = require('del');
var sourcemaps = require('gulp-sourcemaps');
var sdkSrcNoEncryption = [
'src/browser-loader.js', // only needed to be able to use generated files in dist directly in the browser
'dist/index.js' // created by TypeScript compiler
];
var fullSdkSrc = [
'node_modules/node-forge/dist/forge.min.js',
...sdkSrcNoEncryption
];
gulp.task('ts', function () {
var tsProject = ts.createProject('tsconfig.json');
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./')) // combined with tsconfig.json's outFile, this will create ./dist/index.js
.on('end', function() {
return del(['./dist/index.d.ts.map']); // remove sourcemap for TypeScript definition
});
});
gulp.task('createFullSdk', function () {
return gulp.src(fullSdkSrc)
.pipe(sourcemaps.init())
.pipe(concat('connectsdk.js'))
.pipe(gulp.dest('./dist/'))
.pipe(concat('connectsdk.min.js'))
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist/'));
});
gulp.task('createSdkNoEncryption', function () {
return gulp.src(sdkSrcNoEncryption)
.pipe(sourcemaps.init())
.pipe(concat('connectsdk.noEncrypt.js'))
.pipe(gulp.dest('./dist/'))
.pipe(concat('connectsdk.noEncrypt.min.js'))
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist/'));
});
// clean folder
gulp.task('clean', function () {
return del(['./dist']);
});
gulp.task('build', gulp.series('ts', gulp.parallel('createFullSdk', 'createSdkNoEncryption')));
gulp.task('watch', function () {
gulp.watch(['src/*.ts'], gulp.series('build'))
});
gulp.task('default', function () {
console.error('no default task! use gulp --tasks');
});