-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
42 lines (35 loc) · 1.09 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
var browserify = require('browserify'),
gulp = require('gulp');
watchify = require('watchify'),
source = require('vinyl-source-stream'),
connect = require('gulp-connect'),
babelify = require('babelify'),
sourceFile = './index.js',
destFolder = './dist/',
destFile = 'bundle.js';
/* browserify */
gulp.task('watch', function() {
var bundler = browserify({
entries: sourceFile,
cache: {}, packageCache: {}, fullPaths: true, debug: true
});
var bundle = function() {
return bundler
.transform(babelify, { global: true, presets: ["@babel/preset-env"], plugins: ['@babel/plugin-transform-modules-commonjs'] })
.bundle()
.on('error', function (error) { console.error(error) })
.on('end', function() { console.log('[REBUNDLE] Finished') })
.pipe(source(destFile))
.pipe(gulp.dest(destFolder));
};
bundler = watchify(bundler);
bundler.on('update', bundle);
return bundle();
});
gulp.task('serve', function() {
connect.server({
root: './',
livereload: true
});
})
gulp.task('default', gulp.series('watch', 'serve'))