-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
51 lines (44 loc) · 1.25 KB
/
gulpfile.babel.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
47
48
49
50
51
import gulp from 'gulp';
import gutil, { PluginError } from 'gulp-util';
import sourcemaps from 'gulp-sourcemaps';
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
import assign from 'object-assign';
import del from 'del';
import browserify from 'browserify';
import watchify from 'watchify';
import babelify from 'babelify';
import stringify from 'stringify';
gulp.task('build', () => {
const b = browserify('ui/src/index.js', { debug: true })
.transform(stringify({
appliesTo: { includeExtensions: ['.html', '.css'] }
}))
.transform(babelify);
return bundle(b);
});
gulp.task('watch', () => {
const b = browserify('ui/src/index.js', assign({ debug: true }, watchify.args))
.transform(stringify({
appliesTo: { includeExtensions: ['.html', '.css'] }
}))
.transform(babelify);
const w = watchify(b)
.on('update', () => bundle(w))
.on('log', gutil.log);
return bundle(w)
});
gulp.task('clean', () => {
return del('ui/build');
});
function bundle(b) {
return b.bundle()
.on('error', (e) => {
gutil.log(e);
})
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('ui/build'));
}