forked from ma-tu/react-babel-gulp-browserify-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
39 lines (34 loc) · 1012 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
36
37
38
39
var gulp = require('gulp');
var browserify = require('browserify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
var nodemon = require('gulp-nodemon');
var config = {
watchFiles: './src/jsx/*.jsx',
entryFile: './src/jsx/example.jsx',
destDir: './public/scripts/',
destFile: 'example.js',
};
//Browserify
gulp.task('browserify', function() {
browserify(config.entryFile, {debug: true})
.transform(babelify)
.bundle()
.on("error", function (err) {console.log("ERROR: " + err.message);})
.pipe(source(config.destFile))
.pipe(gulp.dest(config.destDir))
});
//Watch Task
gulp.task('watch', function() {
gulp.watch(config.watchFiles, ['browserify'])
});
//Server
gulp.task('server', function () {
nodemon({ script: './server.js'
, ext: 'html js json'
, ignore: ['./node_modules', './src']})
.on('restart', function () {
console.log('restarted!')
})
})
gulp.task('default', ['browserify', 'watch', 'server']);