-
Notifications
You must be signed in to change notification settings - Fork 157
/
gulpfile.js
72 lines (65 loc) · 1.9 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
/**
* Modules
*/
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var header = require('gulp-header');
var rename = require('gulp-rename');
var include = require('gulp-include');
var bump = require('gulp-bump');
var del = require('del');
var pkg = require('./package.json');
/**
* Config
*/
var config = {
name: 'Headhesive',
src: 'src/headhesive.js',
dest: 'dist/',
banner: ['/*!',
' * Headhesive.js v<%= pkg.version %> - <%= pkg.description %>',
' * Author: Copyright (c) <%= pkg.author.name %> <<%= pkg.author.twitter %>> <<%= pkg.author.url %>>',
' * Url: <%= pkg.homepage %>',
' * License: <%= pkg.license %>',
' */',
''].join('\n')
};
/**
* Bump version
*/
var bumpVer = function (bumpType) {
return gulp.src(['./package.json', './bower.json'])
.pipe(bump({
type: bumpType
}))
.pipe(gulp.dest('./'));
}
gulp.task('bump:patch', function () { return bumpVer('patch'); })
gulp.task('bump:minor', function () { return bumpVer('minor'); })
gulp.task('bump:major', function () { return bumpVer('major'); })
/**
* Tasks
*/
gulp.task('clean', function (cb) {
del(['dist'], cb)
});
gulp.task('compile', function () {
return gulp.src(config.src)
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(include())
.pipe(header(config.banner, { pkg: pkg }))
.pipe(uglify({preserveComments: 'some', compress: false, mangle: false, output: { beautify: true, indent_level: 2 }}))
.pipe(gulp.dest(config.dest))
.pipe(uglify({preserveComments: 'some'}))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(config.dest));
});
gulp.task('default', ['clean'], function () {
gulp.start('compile');
});
gulp.task('watch', function () {
gulp.watch(config.src, ['compile']);
});