-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·46 lines (41 loc) · 1.24 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
var gulp = require('gulp');
var browserify = require('browserify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
var uglify = require('gulp-uglify');
var streamify = require('gulp-streamify');
var watch = require('gulp-watch');
var path = {
src: {
app: 'app/src/app.jsx'
},
watch: {
app: 'app/src/**/*.jsx'
},
built: {
app: 'app/built/'
}
};
gulp.task('app:build', function () {
if ('production' == process.env.NODE_ENV) {
return browserify({entries: path.src.app, extensions: ['.jsx'], debug: false})
.transform('babelify', {presets: ['es2015', 'react'], sourceMaps: false})
.bundle()
.pipe(source('app.js'))
.pipe(streamify(uglify()))
.pipe(gulp.dest(path.built.app));
}
else {
return browserify({entries: path.src.app, extensions: ['.jsx'], debug: true})
.transform('babelify', {presets: ['es2015', 'react']})
.bundle()
.pipe(source('app.js'))
.pipe(gulp.dest(path.built.app));
}
});
gulp.task('watch',function () {
watch([path.watch.app], function () {
gulp.start('app:build');
});
});
gulp.task('default', ['watch']);