forked from antonj/viewpager.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
55 lines (45 loc) · 1.56 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
/*global require, exports, module*/
var gulp = require('gulp'),
gutil = require('gulp-util'),
guglify = require('gulp-uglify'),
grename = require('gulp-rename'),
merge = require('merge-stream'),
browserify = require('gulp-browserify'),
jshint = require('gulp-jshint'),
browserSync = require('browser-sync'),
reload = browserSync.reload;
function out(src, standAloneName) {
return gulp.src(src)
.pipe(browserify({
standalone: standAloneName
}).on('error', gutil.log))
.pipe(gulp.dest('./dist'));
}
gulp.task('js', function () {
return merge(out('./src/viewpager.js', 'ViewPager'),
out('./src/gesture_detector.js', 'GestureDetector'),
out('./src/velocity_tracker.js', 'VelocityTracker'));
});
gulp.task('minjs', function () {
return gulp.src(['./dist/*.js', '!./**/*.min.js'])
.pipe(guglify())
.pipe(grename({ extname: '.min.js'}))
.pipe(gulp.dest('./dist'));
});
gulp.task('lint', function() {
return gulp.src(['src/**/*.js'])
.pipe(jshint({ globalstrict: true }))
.pipe(jshint.reporter('default'));
});
gulp.task('browser-sync', function() {
browserSync({ server: { baseDir: './' , directory: true } });
});
gulp.task('watch', function() {
gulp.watch(['./src/**/*.js'], ['js']);
gulp.watch(['./dist/*.js', '!./dist/*.min.js'], ['minjs', reload]);
gulp.watch(['./examples/**/*.js',
'./examples/**/*.html',
'./examples/**/*.css'], reload);
});
gulp.task('dist', ['js', 'minjs']);
gulp.task('default', ['lint', 'js', 'watch', 'browser-sync']);