-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
43 lines (38 loc) · 1.22 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
/*global require */
var
gulp = require('gulp'),
spawn = require('child_process').spawn,
path = require('path'),
plumber = require('gulp-plumber'),
coffee = require('gulp-coffee'),
gutil = require('gulp-util'),
watch = require('gulp-watch'),
include = require('gulp-include'),
uglify = require('gulp-uglify'),
node;
gulp.task('server', function() {
if (node) node.kill()
node = spawn('node', ['server.js'], {stdio: 'inherit'})
node.on('close', function (code) {
if (code === 8) {
gulp.log('Error detected, waiting for changes...');
}
});
})
gulp.task('compile-script', function () {
gulp.src('./src/app.coffee') // path to your file
.pipe(plumber())
.pipe(include())
.pipe(coffee({bare: true}).on('error', gutil.log))
// .pipe(uglify())
.pipe(gulp.dest('./public/js'))
;
});
gulp.task('watch', function () {
gulp.watch('./src/*.coffee', ['compile-script']);
gulp.watch('./server.js', ['server']);
});
gulp.task('default', ['server', 'compile-script', 'watch']);
process.on('exit', function() {
if (node) node.kill()
})