-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
47 lines (38 loc) · 1.28 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
const gulp = require('gulp');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const plumber = require('gulp-plumber');
const buffer = require('vinyl-buffer');
const server = require('gulp-express');
const babel = require('gulp-babel');
gulp.task('transpile-jsx', function() {
return gulp.src('./jsx/**/*.jsx')
.pipe(plumber())
.pipe(babel({
presets: ['react']
}))
.pipe(gulp.dest('./components'));
});
gulp.task('generate-bundle', ['transpile-jsx'], function(){
return browserify({ entries: ['./client/ProductListClient.js'] })
.transform('babelify', {presets: ['es2015']})
.bundle()
.pipe(plumber())
.pipe(source('ProductListClient.bundle.js'))
.pipe(buffer())
.pipe(gulp.dest('./public/js'));
});
gulp.task('reload-app', ['generate-bundle'], function() {
server.run();
});
gulp.task('main', ['generate-bundle'], function () {
// Start the server at the beginning of the task
server.run(['server.js']);
//Components
gulp.watch(['./client/**/*.js', './jsx/**/*.jsx'], ['reload-app']);
//Public files
gulp.watch('./public/**/*.*', server.notify);
//Server
gulp.watch('server.js', server.run);
});
gulp.task('default', ['main']);