forked from kentcdodds/ng2-random-user
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
100 lines (85 loc) · 2.99 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
100
var gulp = require('gulp');
var del = require('del');
var concat = require('gulp-concat');
var plumber = require('gulp-plumber');
var rename = require('gulp-rename');
var traceur = require('gulp-traceur');
var ghPages = require('gulp-gh-pages');
var PATHS = {
src: {
js: 'src/**/*.js',
other: 'src/**/*.{html,css,png}'
},
lib: [
'node_modules/gulp-traceur/node_modules/traceur/bin/traceur-runtime.js',
'node_modules/es6-module-loader/dist/es6-module-loader-sans-promises.src.js',
'node_modules/systemjs/lib/extension-cjs.js',
'node_modules/systemjs/lib/extension-register.js',
'node_modules/angular2/node_modules/zone.js/zone.js',
'node_modules/angular2/node_modules/zone.js/long-stack-trace-zone.js',
'node_modules/angular2/node_modules/rx/dist/rx.all.js',
'node_modules/axios/dist/axios.js',
'node_modules/axios/dist/axios.map',
'node_modules/font-awesome/**/*.*',
'node_modules/moment/moment.js'
]
};
gulp.task('clean', function(done) {
del(['dist'], done);
});
gulp.task('js', function() {
return gulp.src(PATHS.src.js)
.pipe(rename({extname: ''})) //hack, see: https://github.com/sindresorhus/gulp-traceur/issues/54
.pipe(plumber())
.pipe(traceur({
modules: 'instantiate',
moduleName: true,
annotations: true,
types: true,
memberVariables: true
}))
.pipe(rename({extname: '.js'})) //hack, see: https://github.com/sindresorhus/gulp-traceur/issues/54
.pipe(gulp.dest('dist'));
});
gulp.task('other', function() {
return gulp.src(PATHS.src.other)
.pipe(gulp.dest('dist'));
});
gulp.task('libs', ['angular2'], function() {
return gulp.src(PATHS.lib)
.pipe(gulp.dest('dist/lib'));
});
gulp.task('deploy', function() {
return gulp.src('./dist/**/*')
.pipe(ghPages());
});
gulp.task('angular2', function() {
//transpile & concat
return gulp.src([
'node_modules/angular2/es6/prod/*.es6',
'node_modules/angular2/es6/prod/src/**/*.es6'],
{base: 'node_modules/angular2/es6/prod'})
.pipe(rename(function(path) {
path.dirname = 'angular2/' + path.dirname; //this is not ideal... but not sure how to change angular's file structure
path.extname = ''; //hack, see: https://github.com/sindresorhus/gulp-traceur/issues/54
}))
.pipe(traceur({modules: 'instantiate', moduleName: true}))
.pipe(concat('angular2.js'))
.pipe(gulp.dest('dist/lib'));
});
gulp.task('play', ['default'], function() {
var http = require('http');
var connect = require('connect');
var serveStatic = require('serve-static');
var open = require('open');
var port = 9000, app;
gulp.watch(PATHS.src.other, ['other']);
gulp.watch(PATHS.src.js, ['js']);
app = connect().use(serveStatic(__dirname + '/dist')); // serve everything that is static
http.createServer(app).listen(port, function() {
console.log('http://localhost:' + port);
});
});
gulp.task('default', ['js', 'other', 'libs']);
gulp.task('build', ['js', 'other', 'libs']);
gulp.task('gh-pages', ['build', 'deploy']);