-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
81 lines (68 loc) · 1.81 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
'use strict';
var gulp = require('gulp');
// Load plugins
var $ = require('gulp-load-plugins')();
$.connect = require('gulp-connect');
var pkg = require('./package.json');
var banner = [
'/**',
' * <%= pkg.name %>',
' * <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n');
// Scripts
gulp.task('scripts', function () {
return gulp.src('*.js')
.pipe($.jshint('.jshintrc'))
.pipe($.jshint.reporter('default'));
});
// Clean
gulp.task('clean', ['scripts'], function () {
return gulp.src(['dist'], {read: false}).pipe($.rimraf());
});
// Add banner
gulp.task('dist', ['clean'], function() {
gulp.src('pointertouch.js')
.pipe($.header(banner, { pkg: pkg }))
.pipe($.rename('jquery.event.pointertouch.js'))
.pipe(gulp.dest('./dist'))
.pipe($.uglify({ preserveComments: 'some' }))
.pipe($.rename('jquery.event.pointertouch.min.js'))
.pipe(gulp.dest('./dist'));
});
// Update JSON versions
gulp.task('version', ['dist'], function() {
return gulp.src(['bower.json', 'event.pointertouch.jquery.json'])
.pipe($.replace(/("version":\s*")[^"]+(")/, '$1' + pkg.version + '$2'))
.pipe(gulp.dest(__dirname))
.pipe($.jsonlint())
.pipe($.jsonlint.reporter());
});
gulp.task('size', function() {
gulp.src('./dist/jquery.event.pointertouch.min.js')
.pipe($.gzip())
.pipe($.micro({ limit: 550 }));
});
// Default task
gulp.task('default', ['dist']);
// Connect
gulp.task('connect', $.connect.server({
root: [__dirname],
port: 8001,
livereload: true
}));
// Watch
gulp.task('watch', ['connect'], function () {
// Watch for changes in `app` folder
gulp.watch([
'*.js',
'test/index.html',
'test/*.js'
], $.connect.reload);
// Watch gulpfile.js
gulp.watch('gulpfile.js', ['scripts']);
// Watch to rebuild
gulp.watch('./pointertouch.js', ['default']);
});