This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
gulpfile.js
60 lines (49 loc) · 1.52 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
var gulp = require('gulp');
var traceur = require('gulp-traceur');
var connect = require('gulp-connect');
var rename_ = require('gulp-rename');
var TRACEUR_OPTIONS = require('./config').traceur;
var PATH = {
BUILD: './build/',
SRC: './src/**/*.ats',
TEST: './test/**/*.ats'
};
// A wrapper around gulp-rename to support `dirnamePrefix`.
function rename(obj) {
return rename_(function(parsedPath) {
return {
extname: obj.extname || parsedPath.extname,
dirname: (obj.dirnamePrefix || '') + parsedPath.dirname,
basename: parsedPath.basename
};
});
}
// TRANSPILE AT SCRIPT
gulp.task('build/src', function() {
gulp.src(PATH.SRC, {base: '.'})
// Rename before Traceur, so that Traceur has the knowledge of both input and output paths.
.pipe(rename({extname: '.js', dirnamePrefix: PATH.BUILD}))
.pipe(traceur(TRACEUR_OPTIONS))
.pipe(gulp.dest('.'));
});
gulp.task('build/test', function() {
gulp.src(PATH.TEST, {base: '.'})
// Rename before Traceur, so that Traceur has the knowledge of both input and output paths.
.pipe(rename({extname: '.js', dirnamePrefix: PATH.BUILD}))
.pipe(traceur(TRACEUR_OPTIONS))
.pipe(gulp.dest('.'));
});
gulp.task('build', ['build/src', 'build/test']);
// WATCH FILES FOR CHANGES
gulp.task('watch', function() {
gulp.watch(PATH.SRC, ['build']);
});
// WEB SERVER
gulp.task('serve', function() {
connect.server({
root: [__dirname],
port: 8000,
livereload: false
});
});
gulp.task('default', ['serve', 'watch']);