forked from mbalex99/newfamily-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
67 lines (55 loc) · 1.82 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
var gulp = require('gulp');
var path = require('path');
var sourcemaps = require('gulp-sourcemaps');
var ts = require('gulp-typescript');
var del = require('del');
var concat = require('gulp-concat')
var runSequence = require('run-sequence');
// SERVER
gulp.task('clean', function(){
return del('dist')
});
gulp.task('build:server', function () {
var tsProject = ts.createProject('server/tsconfig.json');
var tsResult = gulp.src('server/**/*.ts')
.pipe(sourcemaps.init())
.pipe(ts(tsProject))
return tsResult.js
.pipe(concat('server.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'))
});
// CLIENT
/*
jsNPMDependencies, sometimes order matters here! so becareful!
*/
var jsNPMDependencies = [
'angular2/bundles/angular2-polyfills.js',
'systemjs/dist/system.src.js',
'rxjs/bundles/Rx.js',
'angular2/bundles/angular2.dev.js',
'angular2/bundles/router.dev.js'
]
gulp.task('build:index', function(){
var mappedPaths = jsNPMDependencies.map(file => {return path.resolve('node_modules', file)})
//Let's copy our head dependencies into a dist/libs
var copyJsNPMDependencies = gulp.src(mappedPaths, {base:'node_modules'})
.pipe(gulp.dest('dist/libs'))
//Let's copy our index into dist
var copyIndex = gulp.src('client/index.html')
.pipe(gulp.dest('dist'))
return [copyJsNPMDependencies, copyIndex];
});
gulp.task('build:app', function(){
var tsProject = ts.createProject('client/tsconfig.json');
var tsResult = gulp.src('client/**/*.ts')
.pipe(sourcemaps.init())
.pipe(ts(tsProject))
return tsResult.js
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'))
});
gulp.task('build', function(callback){
runSequence('clean', 'build:server', 'build:index', 'build:app', callback);
});
gulp.task('default', ['build']);