forked from furstenheim/automatic-scatter-labelling
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
104 lines (97 loc) · 2.55 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
const gulp = require('gulp')
const mocha = require('gulp-spawn-mocha')
const browserify = require('browserify')
const babelify = require('babelify')
const exposify = require('exposify')
const watchify = require('watchify')
const source = require('vinyl-source-stream')
const buffer = require('vinyl-buffer')
const browserSync = require('browser-sync').create()
const transform = require('vinyl-transform')
const notify = require('gulp-notify')
gulp.task('start-server', ['build:main'], function () {
browserSync.init({
server: {
baseDir: './'
},
startPath: '/example'
})
})
gulp.task('build:main', function () {
var bundler = watchify(browserify({
standalone: 'automaticScatterLabelling',
entries: [
'./index.js'
],
debug: true
}))
function gulpBundle () {
bundler.bundle()
.on('error', function (err) {
return notify().write(err)
})
.pipe(source('automatic-labelling.js'))
.pipe(buffer())
.pipe(gulp.dest('dist/'))
.on('error', function (e) {
console.error(e)
})
.on('end', function () {
console.log('finished bundling')
browserSync.reload()
})
}
bundler
.transform('exposify', {expose: {lodash: '_'}})
.transform(babelify, {plugins: ['transform-async-to-generator','meaningful-logs']})
.on('update', function (a) {
gulpBundle()
})
.on('error', function (e) {
return notify().write(e)
})
.on('log', function (log) {
console.log(log)
})
return gulpBundle()
})
gulp.task('build', function () {
var bundler = browserify({
standalone: 'automaticScatterLabelling',
entries: [
'./index.js'
]
})
function gulpBundle () {
bundler.bundle()
.on('error', function (err) {
return notify().write(err)
})
.pipe(source('automatic-labelling.js'))
.pipe(buffer())
.pipe(gulp.dest('dist/'))
.on('error', function (e) {
console.error(e)
})
.on('end', function () {
console.log('finished bundling')
browserSync.reload()
})
}
bundler
.transform('exposify', {expose: {lodash: '_'}})
.transform(babelify, {plugins: ['transform-async-to-generator', 'meaningful-logs']})
.on('error', function (e) {
return notify().write(e)
})
.on('log', function (log) {
console.log(log)
})
return gulpBundle()
})
gulp.task('test', function () {
gulp
.src('test/*-test.js')
.pipe(mocha().on('error', console.error))
})
gulp.task('default', ['start-server'])