-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
99 lines (83 loc) · 2.5 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
const gulp = require('gulp');
const gulpClean = require('gulp-clean');
const gulpTypescript = require('gulp-typescript');
const watch = require('gulp-watch');
const webpackStream = require('webpack-stream');
const tsProject = gulpTypescript.createProject('tsconfig.gulp.json');
// Default task
gulp.task('default', ['watch']);
// Compile typescript to dist/
gulp.task('webpack', function () {
var webpackConfig = require('./webpack.config.js');
return gulp.src('./src/client/main.ts')
.pipe(webpackStream(webpackConfig))
.pipe(gulp.dest('dist/client/'));
});
gulp.task('watch-webpack', function() {
var webpackConfig = require('./webpack.config.js');
webpackConfig.watch = true;
return gulp.src('./src/client/main.ts')
.pipe(webpackStream(webpackConfig))
.on('error', swallowError)
.pipe(gulp.dest('dist/client/'));
});
gulp.task('ts-server', function () {
return gulp.src('src/server/**/*.ts')
.pipe(gulpTypescript())
.pipe(gulp.dest('dist/server/'));
});
gulp.task('watch-ts-server', function() {
watch('./src/server/**/*.*', function() {
gulp.start('ts-server');
});
});
gulp.task('ts-setup', function () {
return gulp.src('src/setup/**/*.ts')
.pipe(gulpTypescript())
.pipe(gulp.dest('dist/setup/'));
});
gulp.task('watch-ts-setup', function() {
watch('./src/setup/**/*.*', function() {
gulp.start('ts-setup');
});
});
//Copy client assets
gulp.task('copy-favicon', function() {
return gulp.src('favicon.ico')
.pipe(gulp.dest('dist/client/'));
});
gulp.task('copy-images', function() {
return gulp.src('assets/images/**/*')
.pipe(gulp.dest('dist/client/images/'));
});
gulp.task('watch-copy-images', function() {
return gulp.src('assets/images/**/*')
.pipe(watch('assets/images/**/*'))
.pipe(gulp.dest('dist/client/images/'));
});
gulp.task('copy-vendor', function() {
return gulp.src('vendor/**/*')
.pipe(gulp.dest('dist/client/vendor/'));
});
// Clean
gulp.task('clean', function() {
return gulp.src('dist/')
.pipe(gulpClean());
});
// Build
gulp.task('build', [
'webpack', 'ts-server', 'ts-setup',
'copy-favicon', 'copy-images', 'copy-vendor'
]);
// Watch
gulp.task('watch', [
'webpack', 'ts-server', 'ts-setup',
'copy-favicon', 'copy-images', 'copy-vendor',
'watch-webpack', 'watch-ts-server', 'watch-ts-setup',
'watch-copy-images'
]);
// Catch errors for watch tasks that don't
function swallowError(error) {
//Ignore error
//console.log(error.toString());
}