forked from ibhi/angular-2-router-with-child
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
74 lines (63 loc) · 2.04 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
'use strict';
var gulp = require('gulp');
var del = require('del');
var Builder = require('systemjs-builder');
var ts = require('gulp-typescript');
var plumber = require('gulp-plumber');
var sourcemaps = require('gulp-sourcemaps');
var http = require('http');
var connect = require('connect');
var serveStatic = require('serve-static');
var openResource = require('open');
gulp.task('clean', function (done) {
del(['dev'], done);
});
gulp.task('build:angular2', function () {
var builder = new Builder({
paths: {
'angular2/*': 'node_modules/angular2/es6/prod/*.es6',
rx: 'node_modules/angular2/node_modules/rx/dist/rx.js'
},
meta: {
rx: {
format: 'cjs'
}
}
});
builder.build('angular2/router', './lib/router.js', {});
return builder.build('angular2/angular2', './lib/angular2.js', {});
});
gulp.task('build:lib', ['build:angular2'], function () {
gulp.src([
'./node_modules/angular2/node_modules/traceur/bin/traceur-runtime.js',
'./node_modules/angular2/node_modules/zone.js/dist/zone.js',
'./node_modules/es6-module-loader/dist/es6-module-loader-sans-promises.js',
'./node_modules/es6-module-loader/dist/es6-module-loader-sans-promises.js.map',
'./node_modules/reflect-metadata/Reflect.js',
'./node_modules/reflect-metadata/Reflect.js.map',
'./node_modules/systemjs/dist/system.js',
'./node_modules/systemjs/dist/system.js.map'
])
.pipe(gulp.dest('./lib'));
});
var tsProject = ts.createProject('tsconfig.json', {
typescript: require('typescript')
});
gulp.task('build', ['clean'], function () {
var result = gulp.src('./ts/**/*.ts')
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(ts(tsProject));
return result.js
.pipe(sourcemaps.write())
.pipe(gulp.dest('./dev'));
});
gulp.task('serve', ['build:lib', 'build'], function () {
var port = 5555;
var app;
gulp.watch('./ts/**', ['build']);
app = connect().use(serveStatic(__dirname));
http.createServer(app).listen(port, function () {
openResource('http://localhost:' + port);
});
});