-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
82 lines (71 loc) · 1.75 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
var gulp = require('gulp'),
gutil = require('gulp-util'),
jshint = require('gulp-jshint'),
stylish = require('jshint-stylish'),
include = require('gulp-include'),
prettify = require('gulp-js-prettify'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
connect = require('gulp-connect'),
colors = require('colors'),
path = {
src : 'src/mantis.js',
build : 'mantis.js',
min : 'mantis.min.js'
};
function logger (event) {
var file = event.path.split(__dirname)[1],
message,
color;
switch (event.type) {
case 'added':
color = 'green';
break;
case 'changed':
color = 'yellow';
break;
case 'deleted':
color = 'red';
break;
}
message = 'The file ' + file.bold.blue + ' was ' + event.type.bold[color];
gutil.log('[Mantis.js] '.green + message);
}
gulp.task('concat', function() {
return gulp.src(path.src)
.pipe(include())
.pipe(prettify({
indent_with_tabs : true,
preserve_newlines : false,
end_with_newline : true
}))
.pipe(gulp.dest('./'));
});
gulp.task('uglify', function() {
return gulp.src(path.build)
.pipe(uglify())
.pipe(rename(path.min))
.pipe(gulp.dest('./'));
});
gulp.task('lint', function () {
return gulp.src(path.build)
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});
gulp.task('connect', function () {
connect.server({
root: __dirname,
livereload: true
});
});
gulp.task('watch', function () {
gulp.watch(['src/*.js', 'playground/*.html'], ['concat']).on('change', function (event) {
logger(event);
});
gulp.watch([path.build], ['uglify', 'lint']).on('change', function (event) {
gulp.src(__dirname)
.pipe(connect.reload());
});
});
gulp.task('build' , ['concat' , 'uglify']);
gulp.task('default' , ['watch' , 'connect']);