-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
79 lines (67 loc) · 1.72 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
67
68
69
70
71
72
73
74
75
76
77
78
79
/*jshint globalstrict: true*/
/*global require*/
'use strict'
const gulp = require('gulp')
const typescript = require('gulp-typescript')
const connect = require('gulp-connect')
const jdists = require('gulp-jdists')
const uglify = require('gulp-uglify')
const rename = require('gulp-rename')
const open = require('gulp-open')
const examplejs = require('gulp-examplejs')
const port = 20173
gulp.task('connect', function () {
connect.server({
port: port,
livereload: true
})
})
gulp.task('watch', function () {
gulp.watch(['./example/*.html', './src/ts/*.ts'], ['build', 'jdists', 'reload'])
})
gulp.task('reload', function () {
gulp.src(['./example/*.html', './src/ts/*.ts'])
.pipe(connect.reload())
})
gulp.task('build', function (done) {
gulp.src('./src/ts/*.ts')
.pipe(typescript({
target: 'ES5'
}))
.pipe(gulp.dest('./src/js'))
.on('end', done);
})
gulp.task('jdists', ['build'], function () {
gulp.src('./src/jchecks.jdists.js')
.pipe(jdists())
.pipe(rename('jchecks.js'))
.pipe(gulp.dest('./'))
})
gulp.task('open', function () {
gulp.src(__filename)
.pipe(open({ uri: `http://localhost:${port}/example/index.html` }))
})
gulp.task('uglify', function () {
gulp.src('jchecks.js')
.pipe(uglify())
.pipe(rename('jchecks.min.js'))
.pipe(gulp.dest('./'))
})
gulp.task('example', function() {
return gulp.src([
'src/ts/*.ts'
])
.pipe(examplejs({
header: `
global.jchecks = require('../jchecks.js');
`,
globals: 'document,NodeFilter',
timeout: 300000,
}))
.pipe(rename({
extname: '.js'
}))
.pipe(gulp.dest('test'))
})
gulp.task('dist', ['jdists', 'uglify'])
gulp.task('debug', ['jdists', 'connect', 'watch', 'open'])