-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
35 lines (30 loc) · 948 Bytes
/
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
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var gutil = require('gulp-util');
var babelify = require('babelify');
var dependencies = ['react', 'react-dom'];
gulp.task('scripts', function() {
bundleApp(false);
});
gulp.task('watch', function() {
gulp.watch(['./src/*.js'], ['scripts']);
});
gulp.task('default', ['scripts', 'watch']);
function bundleApp(isProduction) {
browserify({require: dependencies, debug: true})
.bundle()
.on('error', gutil.log)
.pipe(source('vendors.js'))
.pipe(gulp.dest('./public/js/'));
//
var appBundler = browserify({entries: './src/app.js', debug: true})
// dependencies.forEach(function(dep) {
// appBundler.external(dep);
// })
appBundler.transform(babelify, { presets: ["react", "es2015"] })
.bundle()
.on('error', gutil.log)
.pipe(source('bundle.js'))
.pipe(gulp.dest('./public/js/'));
}