forked from angular/router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
88 lines (76 loc) · 2.2 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
var gulp = require('gulp');
var Dgeni = require('dgeni');
var traceur = require('gulp-traceur');
var connect = require('gulp-connect');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var ngAnnotate = require('gulp-ng-annotate');
var gulpMerge = require('gulp-merge');
var modulate = require('./scripts/angular-modulate');
var uglify = require('gulp-uglify');
var CONFIG = require('./config');
var SERVER_CONFIG = CONFIG.server;
var TRACEUR_OPTIONS = CONFIG.traceur;
var BUILD_DIR = CONFIG.build.dir;
var PATH = {
SRC: './src/**/*',
DOCS: './docs/**/*.md',
ATS: './src/**/*.ats'
};
gulp.task('build', ['transpile', 'angularify']);
gulp.task('transpile', function() {
return gulp.src(PATH.ATS)
.pipe(traceur(TRACEUR_OPTIONS))
.pipe(rename({extname: '.js'}))
.pipe(gulp.dest(BUILD_DIR));
});
gulp.task('angularify', ['transpile'], function() {
var directive = gulp.src('./src/*.es5.js');
var generated = gulp.src(['./src/router.ats', './src/grammar.ats'])
.pipe(modulate({
moduleName: 'ngPhinRouter.generated'
}))
return gulpMerge(directive, generated)
.pipe(concat('router.es5.js'))
.pipe(ngAnnotate())
.pipe(gulp.dest(BUILD_DIR))
.pipe(uglify())
.pipe(rename({extname: '.min.js'}))
.pipe(gulp.dest(BUILD_DIR));
});
gulp.task('dgeni', function() {
try {
var dgeni = new Dgeni([require('./docs/dgeni.conf')]);
return dgeni.generate();
} catch(x) {
console.log(x.stack);
throw x;
}
});
gulp.task('static', function () {
return gulp.src('./docs/*.css', {base: './docs'})
.pipe(gulp.dest('./dist/docs/'));
});
// WATCH FILES FOR CHANGES
gulp.task('watch', function() {
gulp.watch([PATH.SRC, PATH.DOCS], ['build', 'docs']);
});
// WEB SERVER
gulp.task('serve', function() {
connect.server({
host: SERVER_CONFIG.host,
root: [__dirname],
port: SERVER_CONFIG.port,
livereload: false
});
});
gulp.task('docs', ['dgeni', 'static']);
gulp.task('docs/serve', ['docs'], function() {
connect.server({
host: SERVER_CONFIG.host,
root: [__dirname + '/dist/docs'],
port: SERVER_CONFIG.port,
livereload: false
});
});
gulp.task('default', ['build', 'docs', 'serve', 'watch']);