-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
84 lines (70 loc) · 1.54 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
/**
* Gulp dependencies.
*/
var gulp = require('gulp')
var browserify = require('browserify')
var dependify = require('dependify')
var source = require('vinyl-source-stream')
var buffer = require('vinyl-buffer')
var uglify = require('gulp-uglify')
var sourcemaps = require('gulp-sourcemaps')
var gutil = require('gulp-util')
var standard = require('gulp-standard')
var Server = require('karma').Server
/**
* Browserify.
*/
gulp.task('browserify', function () {
// set up the browserify instance on a task basis
var b = browserify({
entries: './jquery-view.js',
debug: true
}).plugin(dependify, {
name: 'View',
deps: {
jquery: 'jQuery'
}
})
return b.bundle()
.pipe(source('jquery-view.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
// Add transformation tasks to the pipeline here.
.pipe(uglify())
.on('error', gutil.log)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/'))
})
/**
* Standard lint.
*/
gulp.task('standard', function () {
return gulp.src(['./src/**/*.js'])
.pipe(standard())
.pipe(standard.reporter('default', {
breakOnError: true
}))
})
/**
* Karma.
*/
gulp.task('karma', function (done) {
new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start()
})
/**
* Test.
*/
gulp.task('test', ['standard', 'karma'])
/**
* Watch.
*/
gulp.task('watch', function () {
gulp.watch('src/**/*.js', ['browserify'])
})
/**
* Default.
*/
gulp.task('default', ['test', 'browserify'])