-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
60 lines (54 loc) · 1.47 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
'use strict'
// DEPENDENCIES
const gulp = require('gulp'),
tslint = require('gulp-tslint'),
ts = require('gulp-typescript'),
nodemon = require('gulp-nodemon')
// TSLINT
gulp.task('ts-lint', () => {
const config = { formatter: 'verbose' }
return gulp.src(['src/**/*.ts'])
.pipe(tslint(config))
.pipe(tslint.report({
reportLimit: 5
}))
})
// COPY FILES
gulp.task('copy-files', () => {
const COPY_FILES = ['package.json']
return gulp.src(COPY_FILES)
.pipe(gulp.dest('dist'))
})
// WATCH
gulp.task('watch', (done) => {
gulp.watch('./**/*.ts')
nodemon({
script: 'dist/server.js',
tasks: ['build'],
ext: 'ts json',
ignore: ['node_modules/', 'package.json', 'tsconfig.json']
}).on('restart', () => {
console.log('##################################### // ######################################')
console.log('########################### (0/ Server restarted... ###########################')
}).on('crash', function () {
console.error('Application has crashed!')
})
done()
})
// BUILD DEFAULT
gulp.task('build', gulp.series(['ts-lint', 'copy-files'], function compiler() {
const tsProject = ts.createProject(
'tsconfig.json',
{ typescript: require('typescript') }
)
return tsProject.src()
.pipe(tsProject())
.js.pipe(gulp.dest('dist'))
.on('error', (err) => {
console.error('Build error:', err.message)
// process.exit(1)
})
}
))
// BUILD DEV
gulp.task('dev', gulp.series(['build', 'watch']))