This repository was archived by the owner on Nov 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgulpfile.js
More file actions
84 lines (70 loc) · 1.93 KB
/
gulpfile.js
File metadata and controls
84 lines (70 loc) · 1.93 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
var fs = require('fs'),
gulp = require('gulp'),
clean = require('gulp-clean'),s
concat = require('gulp-concat'),
htmlmin = require('gulp-htmlmin'),
gulpSequence = require('gulp-sequence'),
stringReplace = require('gulp-string-replace'),
uglify = require('gulp-uglify'),
util = require("gulp-util"),
watch = require('gulp-watch'),
ts = require("gulp-typescript"),
tsProject = ts.createProject("tsconfig.json");
gulp.task('default', ['build']);
gulp.task('watch', function () {
return watch('src/**/*.*', function () {
gulp.start('devbuild');
});
});
gulp.task('compile', function () {
var template = fs.readFileSync('build/template/template.html', 'utf-8', function (err, data) {
return data.toString()
});
return tsProject.src()
.pipe(tsProject())
.js
.pipe(
stringReplace(
'REPLACE_WITH_TEMPLATE_HTML',
template
)
)
.pipe(gulp.dest(""));
});
gulp.task('html', function () {
return gulp.src('src/*.html')
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('build/template'));
});
gulp.task('minify', function () {
return gulp.src('build/js/kyc.sdk.js')
.pipe(uglify())
.on('error', function (err) {
util.log(util.colors.red('[Error]'), err.toString());
})
.pipe(concat('kyc.sdk.min.js'))
.pipe(gulp.dest('build/js'));
});
gulp.task('dist', function () {
return gulp.src('build/js/*.js')
.pipe(gulp.dest('./dist'))
;
});
gulp.task('cleanup', function () {
return gulp.src('build')
.pipe(clean({read:false,force: true}))
});
gulp.task('devbuild', function (c) {
gulpSequence(
'html',
'compile',
'minify',
'dist',
)(c);
});
gulp.task('build', function (c) {
gulpSequence(
'devbuild',
'cleanup',
)(c);
});