-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
70 lines (58 loc) · 1.68 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
/*eslint-disable*/
var gulp = require('gulp');
var runSequence = require('run-sequence');
var del = require('del');
var babel = require('gulp-babel');
var karma = require('karma').server;
var browserify = require('browserify');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var source = require('vinyl-source-stream');
var config = require('./config');
var eslint = require('gulp-eslint');
var path = require('path');
gulp.task('lint', function () {
return gulp.src(config.src)
.pipe(eslint())
.pipe(eslint.format());
});
gulp.task('build', function (done) {
runSequence('build:clean', 'lint', 'transpile', done);
});
gulp.task('build:clean', function (done) {
del([config.build], done);
});
gulp.task('transpile', function () {
return gulp.src(config.src)
.pipe(babel(config.babel))
.pipe(gulp.dest(config.build));
});
gulp.task('dist', function (done) {
runSequence(['build', 'dist:clean'], 'browserify', 'compress', done);
});
gulp.task('dist:clean', function (done) {
del([config.dist], done);
});
gulp.task('browserify', function () {
return browserify(config.browserify).bundle()
.pipe(source(config.browserify.outputName))
.pipe(gulp.dest(config.dist));
});
gulp.task('compress', function () {
return gulp.src(config.dist + '/' + config.browserify.outputName)
.pipe(uglify())
.pipe(rename(config.releaseName))
.pipe(gulp.dest(config.dist));
});
gulp.task('test', function (done) {
karma.start({
configFile: config.test.karmaConfig,
singleRun: true
}, done);
});
gulp.task('release', function (done) {
runSequence('dist', done);
});
gulp.task('default', function (done) {
runSequence('build', done);
});