-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
41 lines (36 loc) · 1.14 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
var gulp = require('gulp');
var gulpNodemon = require('gulp-nodemon');
var gulpWatch = require('gulp-watch');
var gulpBabel = require('gulp-babel');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
// Compile all .jsx files in "views/" subdirectory to .js files
gulp.task('jsx', function() {
return gulp.src(['app/**/*.jsx', 'app/**/*.js'])
.pipe(gulpBabel())
.pipe(gulp.dest('bin'));
});
gulp.task('client-scripts', ['jsx'], function() {
return browserify('./bin/assets/js/index.js').bundle()
.pipe(source('index.js'))
.pipe(gulp.dest('bin/assets/js'));
});
// Watch for changes to .jsx file
gulp.task('watch-jsx', ['client-scripts'], function() {
gulpWatch(['app/**/*.jsx', 'app/**/*.js'], function() {
gulp.start('client-scripts');
});
});
// 'node' task depends on 'jsx' task
// start the server
gulp.task('node', ['watch-jsx'], function() {
gulpNodemon({
script: 'bin/server.js',
ignore: ['gulpfile.js'],
ext: 'jxt js'
});
});
// default gulp task
gulp.task('default', function() {
gulp.start('node');
});