-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
76 lines (62 loc) · 1.81 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
var _ = require('lodash'),
gulp = require('gulp'),
coffee = require('gulp-coffee'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
http = require('http'),
connect = require('connect'),
qunit = require('gulp-qunit'),
paths = {
scripts: ['src/**/*.coffee'],
compiled: ['src/**/*.js'],
tests: ['tests/**/*.coffee'],
qunitHtml: ['tests/index.html'],
demo: ['demo/*.html']
};
function create_static_server () {
var app = connect()
.use(connect.static(__dirname));
http.createServer(app).listen(3000);
console.log('server running on localhost:3000');
}
//compiles coffee script files
gulp.task('compile', function () {
gulp.src(paths.scripts)
.pipe(coffee())
.pipe(gulp.dest('src'));
gulp.on('error', function () {
console.log('error');
});
gulp.src(paths.tests)
.pipe(coffee())
.pipe(gulp.dest('tests'));
});
// uglify (aka minify)
gulp.task('compress', function() {
gulp.src(paths.compiled)
.pipe(uglify({outSourceMap: true}))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist'));
});
gulp.task('copy', function () {
gulp.src(paths.compiled)
.pipe(gulp.dest('dist'));
gulp.src('src/index.html')
.pipe(gulp.dest('dist'));
});
gulp.task('qunit', function () {
return gulp.src(paths.qunitHtml).pipe(qunit());
});
// recompile coffeescript files on change
gulp.task('watch', function () {
gulp.watch(paths.scripts, ['test']);
gulp.watch(paths.tests, ['test']);
});
// launch this repo as a server (port 3000)
gulp.task('serve', create_static_server);
// builds everything to the `dist` directory
gulp.task('build', ['compile', 'copy', 'compress']);
// does a build and runs the qunit tests
gulp.task('test', ['build', 'qunit']);
// runs a build and launches a server
gulp.task('default', ['test', 'watch', 'serve']);