forked from jellekralt/Responsive-Tabs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
97 lines (83 loc) · 2.05 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var bump = require('gulp-bump');
var header = require('gulp-header');
var modRewrite = require('connect-modrewrite');
var qunit = require('node-qunit-phantomjs');
var runSequence = require('run-sequence');
var argv = require('yargs').argv;
var config = {
paths: {
scripts: ['./js/jquery.responsiveTabs.js'],
images: 'client/img/**/*'
}
};
gulp.task('release', function(cb) {
runSequence('bump', 'build', cb);
});
// Build
gulp.task('build', function() {
var pkg = require('./package.json');
var author = pkg.author.split(' <')[0];
var banner = ['/**',
' * <%= pkg.name %>',
' * ',
' * <%= pkg.description %>',
' * ',
' * @author <%= author %>',
' * @version v<%= pkg.version %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n');
return gulp.src(config.paths.scripts)
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(header(banner, { pkg: pkg, author: author } ))
.pipe(rename({
extname: '.min.js'
}))
.pipe(gulp.dest('js/'));
});
// Bump
gulp.task('bump', function() {
var bumpOpts = {};
if ('v' in argv) {
bumpOpts.type = argv.v;
}
return gulp.src(['./package.json'])
.pipe(bump(bumpOpts))
.pipe(gulp.dest('./'));
});
// Lint
gulp.task('lint', function() {
return gulp.src(config.paths.scripts)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Test
gulp.task('test', function() {
qunit('./test/fixture.html');
});
// Watch
gulp.task('watch', function() {
gulp.watch(config.paths.scripts, ['lint']);
});
// Serve
gulp.task('serve', ['watch'], function() {
browserSync.init({
server: {
baseDir: './',
middleware: [
modRewrite([
'^/$ /demo.html'
])
]
}
});
gulp.watch('*.html').on('change', browserSync.reload);
});
gulp.task('default', ['serve']);