-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
61 lines (52 loc) · 1.51 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
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
react = require('gulp-react'),
plumber = require('gulp-plumber'),
through =require('through2');
// Plumber handler which beeps on error
var errorHandler = function(error) {
console.log(error.toString());
process.stderr.write('\x07');
}
// Beeps on error
var JsLintBeepReporter = function() {
return through.obj(function(file, enc, cb) {
if (file.isNull()) {
// return empty file
cb(null, file);
}
if (!file.jshint.success) {
process.stderr.write('\x07');
}
cb(null, file);
});
};
// 'jsx' transforms all the JSX into JS
gulp.task('jsx', function() {
return gulp.src('./src/**/*.jsx')
.pipe(plumber({
errorHandler: errorHandler
}))
.pipe(react())
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(JsLintBeepReporter())
.pipe(gulp.dest('dist/'));
});
gulp.task('js', function() {
return gulp.src('./src/**/*.js')
.pipe(plumber({
errorHandler: errorHandler
}))
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(JsLintBeepReporter())
.pipe(gulp.dest('dist/'));
});
// 'watch' reruns 'jsx' when files are modified
gulp.task('watch', function() {
gulp.watch('./src/jsx/*.jsx', ['jsx']);
gulp.watch('./src/**/*.js', ['js']);
});
gulp.task('default', ['watch', 'jsx', 'js']);
gulp.task('build', ['jsx', 'js']);