This repository has been archived by the owner on May 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgulpfile.js
55 lines (44 loc) · 1.49 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
var gulp = require('gulp');
var colors = require('colors');
var spawn = require('child_process').spawn;
var browserify = require('browserify');
var watchify = require('watchify');
var coffeeify = require('coffeeify');
var vinylSource = require('vinyl-source-stream');
var $ = require('gulp-load-plugins')({
config: require.resolve('./package.json'),
lazy: false
});
var paths = {
dist: './dist',
distFiles: './dist/**/*'
};
gulp.task('default', ['server', 'scripts', 'watch']); // TODO 'styles' once scss is replaced with less
gulp.task('server', function() {
var serverStream = spawn('node', ['server.js']);
serverStream.stdout.on('data', function(data) {
console.log('\n[' + 'nutrients-per-calorie'.green + '] ' + data);
});
});
gulp.task('scripts', function() {
var bundler = watchify(browserify('./src/index.coffee', watchify.args));
bundler.transform(coffeeify);
bundler.on('update', rebundle);
function rebundle() {
return bundler.bundle()
.on('error', $.util.log.bind($.util, 'Browserify Error'))
.pipe(vinylSource('app.js'))
.pipe(gulp.dest(paths.dist));
}
return rebundle();
});
gulp.task('styles', function() {
spawn('compass watch sass/main.scss');
});
gulp.task('watch', ['server'], function() {
// $.watch({glob: paths.css}, ['styles']); // TODO once scss is replaced with less
$.livereload.listen(35729);
$.watch({glob: paths.distFiles}).on('data', function(file) {
$.livereload.changed(file.path);
});
});