-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgulpfile.js
52 lines (44 loc) · 1.21 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
var browserSync = require('browser-sync');
var gulp = require('gulp');
var LiveServer = require('gulp-live-server');
var source = require('vinyl-source-stream');
var babelify = require('babelify');
var browserify = require('browserify');
var reactify = require('reactify');
gulp.task('live-server',function(){
var server = new LiveServer('server/server.js');
server.start();
});
gulp.task('bundle',function(){
return browserify({
entries:'app/main.jsx',
debug:true,
})
.transform(babelify)
.transform(reactify)
.transform(babelify.configure({
stage:0,
sourceMaps:true
}))
.bundle()
.pipe(source('app.js'))
.pipe(gulp.dest('./.tmp'));
});
gulp.task('temp',function(){
gulp.src(['app/index.html','app/*.css'])
.pipe(gulp.dest('./.tmp'));
gulp.src(['bower_components/**'])
.pipe(gulp.dest('./.tmp/bower_components'));
});
gulp.task('bundle-n-reload',['bundle'],browserSync.reload)
gulp.task('observe-all',function(){
gulp.watch('app/**/*.*',['bundle-n-reload']);
gulp.watch('app/*.*',['temp']);
gulp.watch('./server/**/*.js',['live-server']);
});
gulp.task('serve', ['live-server','bundle','temp','observe-all'], function() {
browserSync.init(null, {
proxy: "http://localhost:7777",
port: 9003
});
});