forked from forthebadge/for-the-badge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
74 lines (63 loc) · 1.84 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
'use strict';
var fs = require('fs');
var gulp = require('gulp');
var p = require('gulp-load-plugins')();
var handle = function(err) {
console.log(err); this.emit('end');
};
gulp.task('server', function() {
return p.connect.server({
root: 'dist',
port: 8000,
livereload: true
});
});
gulp.task('jade', function() {
var locals = {badges: fs.readdirSync('./src/images/badges')};
return gulp.src('src/views/*.jade')
.pipe(p.jade({locals: locals}))
.on('error', handle)
.pipe(gulp.dest('dist/'))
.pipe(p.connect.reload());
});
gulp.task('sass', function() {
return gulp.src('src/style/style.scss')
.pipe(p.sass({outputStyle: 'compressed'}))
.on('error', handle)
.pipe(gulp.dest('dist/'))
.pipe(p.connect.reload());
});
gulp.task('scripts', function() {
return gulp.src('src/scripts/**/*.js')
.pipe(p.concat('main.js'))
.on('error', handle)
.pipe(p.uglify())
.on('error', handle)
.pipe(gulp.dest('dist/'))
.pipe(p.connect.reload());
});
gulp.task('images', function() {
return gulp.src('src/images/**/*')
.pipe(p.imagemin())
.on('error', handle)
.pipe(gulp.dest('dist/images'))
.pipe(p.connect.reload());
});
gulp.task('favicon', function() {
return gulp.src('src/images/favicon/*')
.pipe(gulp.dest('dist'));
});
gulp.task('badges', function() {
return gulp.src('src/images/badges/**/*')
.pipe(p.imagemin())
.on('error', handle)
.pipe(gulp.dest('dist/badges'));
});
gulp.task('watch', function() {
gulp.watch('src/views/**/*.jade', ['jade']);
gulp.watch('src/style/**/*.scss', ['sass']);
gulp.watch('src/scripts/**/*.js', ['scripts']);
gulp.watch('src/images/**/*', ['images']);
});
gulp.task('default', ['server', 'jade', 'sass', 'scripts', 'images', 'favicon', 'watch']);
gulp.task('build', ['jade', 'sass', 'scripts', 'images', 'favicon', 'badges']);