-
Notifications
You must be signed in to change notification settings - Fork 14
/
gulpfile.babel.js
62 lines (52 loc) · 1.62 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
52
53
54
55
56
57
58
59
60
61
62
import gulp from 'gulp';
import gutil from 'gulp-util';
import babel from 'gulp-babel';
import browserify from 'gulp-browserify';
import rename from 'gulp-rename';
import connect from 'gulp-connect';
import gbump from 'gulp-bump';
gulp.task('watch', function() {
gulp.watch('./src/**/*', ['build']);
gulp.watch('./test/**/*', ['build:tests']);
});
function bump(type) {
gulp.src(['./bower.json', './package.json'])
.pipe(gbump({type}))
.pipe(gulp.dest('./'));
}
gulp.task('bump:major', () => { bump('major'); });
gulp.task('bump:minor', () => { bump('minor'); });
gulp.task('bump:patch', () => { bump('patch'); });
gulp.task('build:node', () => {
gulp.src('./src/*.js')
.pipe(babel().on('error', gutil.log))
.pipe(gulp.dest('./lib', {overwrite: true}));
});
gulp.task('build:browser', ['build:node'], () => {
gulp.src('./lib/standalone.js')
.pipe(browserify({
standalone: 'Controllables',
transform: ['browserify-shim'],
}))
.pipe(rename('react-controllables.js'))
.pipe(gulp.dest('./standalone/', {overwrite: true}));
});
gulp.task('build:tests', () => {
gulp.src(['./test/tests**.js', '!**/*-compiled.js'])
.pipe(babel().on('error', gutil.log))
.pipe(browserify({
transform: ['browserify-shim'],
}))
.pipe(rename({suffix: '-compiled'}))
.pipe(gulp.dest('./test/', {overwrite: true}));
});
gulp.task('testserver', connect.server({
root: [__dirname],
port: 1337,
open: {
file: 'test/index.html',
browser: 'Google Chrome',
},
}));
gulp.task('test', ['build:browser', 'build:tests', 'testserver']);
gulp.task('build', ['build:node', 'build:browser']);