This repository has been archived by the owner on Sep 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.js
97 lines (80 loc) · 2.8 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
var gulp = require('gulp');
var del = require('del');
var plumber = require('gulp-plumber');
var rename = require('gulp-rename');
var traceur = require('gulp-traceur');
var PATHS = {
src: {
js: 'src/**/*.js',
html: 'src/**/*.html',
css: 'src/**/*.css',
},
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-register.js',
'node_modules/angular2/node_modules/zone.js/zone.js',
'node_modules/angular2/node_modules/zone.js/long-stack-trace-zone.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('html', function () {
return gulp.src(PATHS.src.html)
.pipe(gulp.dest('dist'));
});
gulp.task('css', function () {
return gulp.src(PATHS.src.css)
.pipe(gulp.dest('dist'));
});
gulp.task('libs', ['angular2'], function () {
var size = require('gulp-size');
return gulp.src(PATHS.lib)
.pipe(size({showFiles: true, gzip: true}))
.pipe(gulp.dest('dist/lib'));
});
gulp.task('bower', function() {
return gulp.src('bower_components/**')
.pipe(gulp.dest('dist/bower_components'));
});
gulp.task('angular2', function () {
var buildConfig = {
paths: {
"angular2/*": "node_modules/angular2/es6/prod/*.es6",
"rx/*": "node_modules/angular2/node_modules/rx/*.js"
}
};
var Builder = require('systemjs-builder');
var builder = new Builder(buildConfig);
return builder.build('angular2/angular2', 'dist/lib/angular2.js', {});
});
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.html, ['html']);
gulp.watch(PATHS.src.js, ['js']);
gulp.watch(PATHS.src.css, ['css']);
app = connect().use(serveStatic(__dirname + '/dist')); // serve everything that is static
http.createServer(app).listen(port, function () {
open('http://localhost:' + port);
});
});
gulp.task('default', ['js', 'html', 'css', 'libs', 'bower']);