-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
59 lines (52 loc) · 1.27 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import gulp from 'gulp';
import eslint from 'gulp-eslint';
import ava from 'gulp-ava';
/* React */
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
import browserify from 'browserify';
import babelify from 'babelify';
import sourcemaps from 'gulp-sourcemaps';
var dependencies = [
'react'
];
gulp.task('lint', () => {
return gulp.src(['**/*.js', '!node_modules/**', '!public/**'])
.pipe(eslint())
.pipe(eslint.format());
});
gulp.task('vendors', () => {
return browserify()
.require(dependencies)
.bundle()
.pipe(source('vendor.bundle.js'))
.pipe(buffer())
.pipe(gulp.dest('public/js'));
});
gulp.task('react', ['vendors'], () => {
return browserify({
entries: 'templates/**/index.jsx',
debug: true
})
.external(dependencies)
.transform(babelify, {
presets: ['es2016', 'react']
})
.bundle()
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(sourcemaps.init({
loadMaps: true
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('public/js'));
});
gulp.task('ava', () =>
gulp.src([
'templates/**/test/*.spec.js',
'test/*.spec.js'
])
.pipe(ava())
);
gulp.task('test', ['lint', 'ava']);
gulp.task('build', ['react']);