-
Notifications
You must be signed in to change notification settings - Fork 30
/
gulpfile.js
62 lines (54 loc) · 1.43 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
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
haml = require('gulp-haml'),
minifyCss = require('gulp-minify-css');
// Check JS for errors
gulp.task('lint', function() {
return gulp.src('js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Minify JS
gulp.task('scripts', function() {
return gulp.src('js/*.js')
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.on('error', onError)
.pipe(gulp.dest('js/min'));
});
// Compile & minify SASS
gulp.task('styles', function() {
return gulp.src('sass/*.sass')
.pipe(sass())
.on('error', onError)
.pipe(gulp.dest('css'))
.pipe(minifyCss())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('css/min'))
.pipe(concat('all.min.css'))
.pipe(gulp.dest('css/min'));
});
// Compile index.html
gulp.task('index', function() {
gulp.src('index.haml')
.pipe(haml())
.on('error', onError)
.pipe(gulp.dest('./'));
});
// Watch for changes
gulp.task('watch', function() {
gulp.watch('js/*.js', ['lint', 'scripts']);
gulp.watch('sass/*.sass', ['styles']);
gulp.watch('index.haml', ['index']);
});
// Error logging
function onError(err) {
console.log(err);
this.emit('end');
}
// Run tasks
gulp.task('default', ['lint', 'scripts', 'styles', 'index', 'watch']);