-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
45 lines (36 loc) · 1022 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
40
41
42
43
44
45
// gulpfile.js
var gulp = require('gulp');
var gutil = require('gulp-util');
var source = require('vinyl-source-stream');
var babelify = require('babelify');
var watchify = require('watchify');
var browserify = require('browserify');
var browserSync = require('browser-sync').create();
watchify.args.debug = true;
var bundler = watchify(browserify('./src/script.js', watchify.args));
bundler.transform(babelify.configure({
presets: ["es2015", "react"]
}));
bundler.on('update', bundle);
function bundle() {
gutil.log('Bundling...');
return bundler.bundle()
.on('error', function (err) {
gutil.log(err.message);
this.emit("end");
})
.pipe(source('bundle.js'))
.pipe(gulp.dest('dist'))
.pipe(browserSync.stream({once: true}));
}
gulp.task('bundle', function () {
return bundle();
});
gulp.task('default', ['bundle'], function () {
browserSync.init({
server: "./"
});
gulp.watch('index.html', function() {
browserSync.reload();
})
});