-
Notifications
You must be signed in to change notification settings - Fork 8
/
gulpfile.js
43 lines (39 loc) · 1.33 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
var gulp = require('gulp');
var mocha = require('gulp-mocha');
var gutil = require('gulp-util');
var browserify = require('browserify');
var babelify = require('babelify');
var uglify = require('gulp-uglify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var sourcemaps = require('gulp-sourcemaps');
gulp.task('browserify', function() {
return browserify('./demo/javascript/src/demo.js')
.bundle()
.on('error', function(err){
console.log(err.toString());
this.emit('end');
})
.pipe(source('bundle.js'))
.pipe(gulp.dest('./demo/javascript/build/'));
});
gulp.task('build', function() {
return browserify('./SeamCarver.js')
.transform("babelify", { presets: ["es2015"] })
.bundle()
.pipe(source('SeamCarver.min.js'))
.pipe(buffer())
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write('./maps'))
.on('error', function(err){console.log(err.toString()); this.emit('end'); })
.pipe(gulp.dest('./'))
});
gulp.task('test', function() {
return gulp.src('test.js', {read: false})
.pipe(mocha({reporter: 'spec'}))
.on('error', gutil.log);
});
gulp.task('default', function() {
gulp.watch(['./**/*.js', './*.js'], ['browserify', 'test']);
});