-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
139 lines (128 loc) · 3.11 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/* Make JShint stop yelling: DO NOT REMOVE */
/* jshint undef:false, unused:false, strict:false */
//
// Plugins
//
var
gulp = require('gulp'),
plumber = require('gulp-plumber'),
gutil = require('gulp-util'),
notify = require('gulp-notify'),
watch = require('gulp-watch'),
stylus = require('gulp-stylus'),
sourcemaps = require('gulp-sourcemaps'),
jade = require('gulp-jade'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
jshint = require('gulp-jshint'),
stylish = require('jshint-stylish'),
refresh = require('gulp-livereload'),
axis = require('axis'),
jeet = require('jeet'),
rupture = require('rupture');
//
// Sources
//
var sources = {
images : 'img/**/*',
favicon : 'favicon.ico',
videos : 'video/**/*',
stylus : 'stylus/**/*',
fonts : 'fonts/**/*',
javascripts : 'js/*.js',
vendorjs : [
'js/vendor/jquery.waypoints.js',
'js/vendor/jquery.ba-hashchange.js',
'js/vendor/headroom.js',
'js/vendor/jQuery.headroom.js'
],
jade : 'views/**/*'
};
//
// Destinations
//
var destinations = {
root : '',
images : 'public/img/',
videos : 'public/video',
styles : 'public/css/',
fonts : 'public/fonts/',
javascripts : 'public/js/'
};
//
// Stylus task
//
gulp.task('stylus', function () {
gulp.src('./stylus/site.styl')
.pipe(plumber({
errorHandler: notify.onError({
sound: 'Purr',
title: "Stylus Error:",
message: "<%= error.message %>"})
}))
.pipe(sourcemaps.init())
.pipe(stylus({
use: [axis(), jeet(), rupture()],
compress: true,
linenos: false
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest(destinations.styles))
.pipe(refresh());
});
//
// Javascript tasks
//
gulp.task('scripts', function() {
return gulp.src(sources.javascripts)
.pipe(jshint()
.on('error', gutil.beep))
.pipe(jshint.reporter(stylish))
.pipe(plumber())
.pipe(concat('main.js'))
.pipe(gulp.dest(destinations.javascripts))
.pipe(uglify())
.pipe(gulp.dest(destinations.javascripts))
.pipe(refresh());
});
gulp.task('vendorjs', function() {
return gulp.src(sources.vendorjs)
.pipe(jshint()
.on('error', gutil.beep))
.pipe(jshint.reporter(stylish))
.pipe(plumber())
.pipe(concat('vendor.js'))
.pipe(gulp.dest(destinations.javascripts))
.pipe(uglify())
.pipe(gulp.dest(destinations.javascripts));
});
//
// Jade task
//
gulp.task('jade', function() {
gulp.src('views/pages/*')
.pipe(jade({}))
.pipe(gulp.dest('public/'))
.pipe(refresh());
});
//
// Watch tasks
//
gulp.task('watch', ['build'], function() {
refresh.listen();
gulp.watch(sources.stylus, ['stylus']);
gulp.watch(sources.styluschild, ['stylus']);
gulp.watch(sources.jade, ['jade']);
gulp.watch(sources.javascripts, ['scripts']);
gulp.watch(sources.vendorjs, ['vendorjs']);
});
//
// Task runners
//
gulp.task('default', ['build'], function () {
process.exit(0);
});
//
// Assets Only
//
gulp.task('build', ['stylus', 'scripts', 'vendorjs']);