-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
57 lines (48 loc) · 1.23 KB
/
gulpfile.js
File metadata and controls
57 lines (48 loc) · 1.23 KB
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
var gulp = require('gulp'),
eslint = require('gulp-eslint'),
serve = require('gulp-serve'),
browserify = require('browserify'),
reactify = require('reactify'),
source = require('vinyl-source-stream'),
colors = require('colors');
var swallowError = function(e) {
console.log(colors.red(e.message));
console.log(colors.grey(e.stack));
this.emit('end');
};
var cfg = {
jsxFiles: 'app/**/*.jsx',
htmlFiles: 'app/**/*.html',
mainJs: './main.js',
dist: 'dist',
servePort: 1337
};
gulp.task('default', ['watch']);
gulp.task('watch', function() {
gulp.watch(cfg.jsxFiles, ['react']);
gulp.watch(cfg.htmlFiles, ['html']);
gulp.run('serve');
});
gulp.task('react', ['eslint', 'jsx']);
gulp.task('eslint', function() {
gulp.src(cfg.jsxFiles).
pipe(eslint()).
pipe(eslint.format());
//pipe(eslint.failOnError());
});
gulp.task('jsx', function() {
var b = browserify();
b.transform(reactify);
b.add(cfg.mainJs);
return b.bundle().
on('error', swallowError).
pipe(source(cfg.mainJs)).
pipe(gulp.dest(cfg.dist));
});
gulp.task('html', function() {
gulp.src(cfg.htmlFiles).pipe(gulp.dest(cfg.dist));
});
gulp.task('serve', serve({
root: cfg.dist,
port: cfg.servePort
}));