-
Notifications
You must be signed in to change notification settings - Fork 18
/
gulpfile.js
53 lines (46 loc) · 1.43 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
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
mocha = require('gulp-mocha'),
del = require('del'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename');
gulp.task('clean:dist', function (cb) {
del(['dist/**'], cb);
});
gulp.task('jshint:tests', function () {
return gulp.src(['test/**/*.js'])
.pipe(jshint('./test/.jshintrc'))
.pipe(jshint.reporter('default'));
});
gulp.task('jshint:code', function () {
return gulp.src(['gulpfile.js', './lib/**/*.js'])
.pipe(jshint('./.jshintrc'))
.pipe(jshint.reporter('default'));
});
gulp.task('mochaTest', ['jshint:tests', 'jshint:code'], function () {
return gulp.src('test/**/*.test.js', {read: false})
.pipe(mocha({reporter: 'dot'}));
});
gulp.task('build', function() {
return browserify({
entries: ['./lib/index.js'],
standalone: 'splitter',
builtins: false,
insertGlobals: false
})
.bundle()
.pipe(source('split-sms.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('compress', ['build'], function() {
return gulp.src('dist/split-sms.js')
.pipe(uglify())
.pipe(rename({
extname: '.min.js'
}))
.pipe(gulp.dest('dist'));
});
gulp.task('test', ['jshint:tests', 'jshint:code', 'mochaTest']);
gulp.task('default', ['clean:dist', 'test', 'build', 'compress']);