-
Notifications
You must be signed in to change notification settings - Fork 20
/
gulpfile.js
57 lines (50 loc) · 1.6 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
var gulp = require('gulp');
// Include plugins
var jshint = require('gulp-jshint');
var bower = require('gulp-bower');
var less = require('gulp-less');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var notify = require("gulp-notify");
// Lint
gulp.task('lint', function() {
return gulp.src('js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(notify(
function (file) {
if (file.jshint.success) {
return false;
}
var errors = file.jshint.results.map(function (data) {
if (data.error) {
return "(" + data.error.line + ':' + data.error.character + ') ' + data.error.reason;
}
}).join("\n");
return file.relative + " (" + file.jshint.results.length + " errors)\n" + errors;
}
));
});
// Compile less
gulp.task('less', function() {
return gulp.src('resources/less/*.less')
.pipe(less())
.pipe(gulp.dest('resources/css'));
});
// Concat & minify JS
gulp.task('scripts', function() {
return gulp.src('resources/js/*.js')
.pipe(concat('_all.js'))
.pipe(gulp.dest('resources/js'))
.pipe(rename('all.min.js'))
.pipe(uglify())
.pipe(gulp.dest('resources/js'));
});
// Watch for changes
gulp.task('watch', function() {
gulp.watch('resources/js/*.js', ['lint', 'scripts']);
gulp.watch('resources/less/*.less', ['less']);
});
// Default task
gulp.task('default', ['lint', 'less', 'scripts', 'watch']);