forked from vega/datalib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
39 lines (34 loc) · 987 Bytes
/
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
var gulp = require('gulp'),
browserify = require('browserify'),
buffer = require('vinyl-buffer'),
rename = require('gulp-rename'),
source = require('vinyl-source-stream'),
uglify = require('gulp-uglify'),
gutil = require('gulp-util'),
mocha = require('gulp-spawn-mocha');
function browser() {
return browserify({
entries: ['./src/'],
standalone: 'dl',
debug: true,
cache: {}, packageCache: {}
})
.external(['d3', 'topojson']);
}
function build() {
return browser().bundle()
.pipe(source('datalib.js'))
.pipe(buffer())
.pipe(gulp.dest('.'))
// This will minify and rename to datalib.min.js
.pipe(uglify())
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest('.'));
}
gulp.task('build', function() { build() });
gulp.task('test', function() {
return gulp.src(['test/**/*.js'], { read: false })
.pipe(mocha())
.on('error', gutil.log);
});
gulp.task('default', ['test', 'build']);