-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
88 lines (77 loc) · 1.94 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* gulpfile.js
* Gulp task runner configuration and definitions
*
* Type 'gulp' to see a list (and maybe even a small description) of each task
* available to you.
*
*/
// Included plugins
var gulp = require('gulp'),
livereload = require('gulp-livereload'),
nodemon = require('gulp-nodemon'),
gutil = require('gulp-util'),
del = require('del'),
path = require('path'),
browserify = require('browserify'),
reactify = require('reactify'),
source = require('vinyl-source-stream'),
server = require('./server'),
isDebug = (process.env.NODE_ENV !== 'production'),
vendorLibs = [
'react/addons',
'react-bootstrap',
'async',
'domready',
'request',
'masonry-layout'
];
var reactifyES6 = function (file) {
return reactify(file, {harmony: true});
};
gulp.task('dev', ['watch', 'build', 'server']);
gulp.task('build', ['vendor-js', 'app']);
gulp.task('clean', function () {
del([
'./public/build/**/*.js',
'./public/build/**/*.css'
]);
});
gulp.task('vendor-js', function () {
return browserify({debug:isDebug})
.transform(reactifyES6)
.require(vendorLibs)
.bundle()
.on('error', logAndEndStream)
.pipe(source('vendor.js'))
.pipe(gulp.dest('public/build/js'));
});
gulp.task('app', function () {
return browserify({
entries: ['./app/App.js'],
debug: isDebug
}).transform(reactifyES6)
.external(vendorLibs)
.bundle()
.on('error', logAndEndStream)
.pipe(source('app.js'))
.pipe(gulp.dest('public/build/js'))
.pipe(livereload({auto: false}));
});
gulp.task('watch', function () {
livereload.listen();
gulp.watch([
'./app/components/**/*.js',
'./app/services/**/*.js',
'./app/App.js'
], ['app']);
});
gulp.task('server', function () {
nodemon({ script: 'server.js', ext: 'html js', env : { 'NODE_ENV': 'development' } })
.on('restart', function () {
});
});
function logAndEndStream(err) {
gutil.log(err.stack);
this.end();
}