-
Notifications
You must be signed in to change notification settings - Fork 12
/
gulpfile.babel.js
52 lines (46 loc) · 980 Bytes
/
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
52
import gulp from 'gulp';
import thrift from 'gulp-thrift';
import babel from 'gulp-babel';
const basePaths = {
src: 'src/',
dest: 'lib/'
};
const paths = {
js: {
src: `${basePaths.src}*.js`,
dest: basePaths.dest
},
thrift: {
src: `${basePaths.src}thrift/*.thrift`,
dest: `${basePaths.dest}thrift/`
}
};
/**
* Runs watch task as default.
*/
gulp.task('default', ['watch']);
gulp.task('watch', ['compile:js'], () => {
gulp.watch(paths.js.src, ['compile:js']);
});
/**
* Generates thrift files. This task requires to have thrift
* installed in the system.
*/
gulp.task('thrift', () => {
gulp.src(paths.thrift.src)
.pipe(thrift({
gen: 'js:node'
}))
.pipe(gulp.dest(paths.thrift.dest));
});
/**
* Compiles ES6 code to ES5.
*/
gulp.task('compile:js', () => {
gulp.src(paths.js.src)
.pipe(babel({
presets: ['es2015']
}))
.on('error', console.error.bind(console))
.pipe(gulp.dest(paths.js.dest));
});