-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
78 lines (67 loc) · 1.93 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
//jshint node:true
'use strict';
var gulp = require('gulp'),
babelify = require('babelify'),
browserify = require('browserify'),
connect = require('gulp-connect'),
del = require('del'),
source = require('vinyl-source-stream'),
exorcist = require('exorcist'),
KarmaServer = require('karma').Server,
uglify = require('gulp-uglify'),
streamify = require('gulp-streamify'),
runSequence = require('run-sequence'),
js = 'src/js/**/*.js',
compileJs = function (dist) {
var dest = dist ? 'dist' : 'example';
return browserify('src/js/cat.js', {
debug: true
})
.transform(babelify)
.bundle()
.on('error', function (err) {
console.log('Error : ' + err.message);
})
.pipe(exorcist(dest + '/cat.js.map'))
.pipe(source('cat.js'))
.pipe(gulp.dest(dest));
};
gulp.task('compilejs', function () {
compileJs(true);
});
gulp.task('compilejs-dev', function () {
compileJs(false);
});
gulp.task('build', function () {
return browserify('src/js/cat.js')
.transform(babelify)
.bundle()
.on('error', function (err) {
console.log('Error : ' + err.message);
})
.pipe(source('cat.min.js'))
.pipe(streamify(uglify()))
.pipe(gulp.dest('dist'));
});
gulp.task('karma', function (done) {
new KarmaServer({
configFile: __dirname + '/karma.conf.js'
}, done).start();
});
gulp.task('server', function () {
connect.server({
root: ['example', 'bower_components']
});
});
gulp.task('watch', function () {
gulp.watch([js], ['compilejs-dev']);
});
gulp.task('del:dist', function (done) {
del([
'dist/**/*'
], done);
});
gulp.task('deploy', function (cb) {
runSequence('del:dist', 'compilejs', 'build', cb);
});
gulp.task('default', ['compilejs-dev', 'server', 'watch']);