-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
47 lines (38 loc) · 1.23 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
// Config
const RELEASE_DIR = './dist'
const DEFINITIONS_RELEASE_DIR = RELEASE_DIR + '/definitions'
const JS_RELEASE_DIR = RELEASE_DIR + '/js'
const DEV_DIR = './src'
// Patterns
const DEV_DIR_TS = DEV_DIR + '/**/*.ts'
// Packages
const { task, src, dest, series, watch } = require('gulp'),
plumber = require('gulp-plumber'),
del = require('del'),
ts = require('gulp-typescript'),
merge2 = require('merge2'),
clip = require('gulp-clip-empty-files')
let tsProjectJs = ts.createProject('tsconfig.json', {
declaration: false
})
let tsProjectDefinition = ts.createProject('tsconfig.json', {
declaration: true,
removeComments: false
})
task('clean', function () {
return del([RELEASE_DIR], { force: true })
})
task('scripts', function () {
let tsResource = src(DEV_DIR_TS).pipe(plumber())
return merge2([
// DEFS
tsResource.pipe(tsProjectDefinition()).dts.pipe(clip()).pipe(dest(DEFINITIONS_RELEASE_DIR)),
// JS
tsResource.pipe(tsProjectJs()).js.pipe(clip()).pipe(dest(JS_RELEASE_DIR))
])
})
task('watch', function () {
return watch(DEV_DIR_TS, series(['scripts']))
})
task('build', series(['clean', 'scripts']))
task('default', series(['clean', 'scripts', 'watch']))