forked from affinitybridge/unhcr
-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
53 lines (41 loc) · 1.43 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
var gulp = require('gulp'),
gutil = require('gulp-util'),
sass = require('gulp-sass'),
source = require('vinyl-source-stream'),
watchify = require('watchify'),
pathUtil = require('path');
var dest = path('./');
gulp.task('sass', function () {
gulp.src('./scss/*.scss')
.pipe(sass())
.pipe(gulp.dest('./css'));
});
gulp.task('default', ['watch']);
gulp.task('watch', ['watchify', 'sass'], function() {
gutil.log('running sass');
gulp.watch('./scss/*.scss', ['sass']);
});
gulp.task('watchify', function () {
var bundler = watchify('./src/index.js');
bundler.on('update', rebundle);
bundler.on('log', gutil.log);
function rebundle() {
var stream = bundler.bundle({ debug: true });
stream.on('error', function (err) {
gutil.beep();
gutil.log(err.message);
});
return stream
.pipe(source('app.js'))
.pipe(dest('/js'));
}
return rebundle();
});
function path() {
var base = pathUtil.join.apply(pathUtil, Array.prototype.slice.call(arguments, 0));
return function () {
var args = Array.prototype.slice.call(arguments, 0),
pieces = [base].concat(args);
return gulp.dest(pathUtil.join.apply(pathUtil, pieces));
};
}