This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
173 lines (149 loc) · 4.62 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// get gulp and modules
var gulp = require('gulp'),
connect = require('gulp-connect'),
sass = require('gulp-sass'),
bourbon = require('node-bourbon'),
neat = require('node-neat'),
autoprefix = require('gulp-autoprefixer'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
imagemin = require('gulp-imagemin'),
plumber = require('gulp-plumber'),
concat = require('gulp-concat'),
jade = require('gulp-jade'),
clean = require('gulp-clean'),
resize = require('gulp-image-resize'),
gulpif = require('gulp-if'),
util = require('gulp-util'),
gm = require('gulp-gm'),
deploy = require('gulp-gh-pages'),
// localScreenshots = require('gulp-local-screenshots'),
sitemap = require('gulp-sitemap');
var env = util.env.environment ? util.env.environment : "local"
var events = require('./data/events.json'),
challenges = require('./data/challenges.json');
environment = require('./env/' + (env ? env : "local") + '/configuration.json')
// link public assets
var publicDir = "www";
// start server
gulp.task('connect', function() {
connect.server({
root: publicDir,
port: 9009,
livereload: true
});
});
// minify images
gulp.task('imagemin', function () {
return gulp.src(['img/*', 'img/*/**'])
.pipe(plumber())
.pipe(gulpif('speakers/*', resize({
imageMagick: true,
width : 180,
height : 180,
crop : true,
upscale : true
})))
.pipe(imagemin({progressive: true}))
.pipe(gulp.dest(publicDir + '/img'))
.pipe(connect.reload());
});
gulp.task('fonts', function() {
return gulp.src(['fonts/*'])
.pipe(gulp.dest(publicDir + '/fonts' ))
})
// compile sass to css and prefix
gulp.task('sass', ['fonts'], function () {
gulp.src('sass/*.scss')
.pipe(plumber())
.pipe(sass({
includePaths: neat.includePaths
}))
.pipe(autoprefix('last 10 version'))
.pipe(gulp.dest(publicDir + '/css'))
.pipe(connect.reload());
});
// compiles jade
gulp.task('jade', function() {
// var env = util.env.environment
// if (!env) {
// throw new Error("--environment property is missing (possible values: local, stage, live")
// }
var events = require('./data/events.json'),
challenges = require('./data/challenges.json');
// environment = require('./env/' + env + '/host.json')
gulp.src(['./jade/*.jade', './jade/pages/*/**.jade'])
.pipe(plumber())
.pipe(jade({
pretty: true,
locals: {
"events": events,
"challenges": challenges,
"env": environment
}
}))
.pipe(gulp.dest(publicDir))
.pipe(connect.reload());
});
// clean
gulp.task('clean', function() {
gulp.src(publicDir + '/*', {read: false})
.pipe(plumber())
.pipe(clean());
});
// contact js and minify
gulp.task('uglify', function() {
gulp.src(['js/**/jquery.js', 'js/**/*.js', 'js/*.js'])
.pipe(plumber())
.pipe(concat('main.js'))
// .pipe(uglify())
.pipe(gulp.dest(publicDir + '/js'))
.pipe(connect.reload());
});
// copy video
gulp.task('video', function() {
gulp.src(['video/*'])
.pipe(plumber())
.pipe(gulp.dest(publicDir + '/video'))
.pipe(connect.reload());
});
// copy other resources
gulp.task('copy', function() {
return gulp.src(['favicon.ico', 'humans.txt', 'robots.txt', 'googlef8dbbdd1b207ac7f.html'])
.pipe(gulp.dest(publicDir))
.pipe(connect.reload());
});
gulp.task('watch', function() {
gulp.watch(['js/*.js', 'js/**/*.js'], ['uglify']);
gulp.watch(['img/*', 'img/**/*'], ['imagemin']);
gulp.watch(['sass/*.scss', 'sass/**/*.scss'], ['sass']);
gulp.watch(['jade/*.jade', 'jade/**/*.jade'], ['jade']);
gulp.watch(['favicon.ico', 'humans.txt', 'robots.txt', 'cd'], ['copy']);
gulp.watch(['video/*'], ['video']);
});
// gulp.task('screens', ['copy', 'imagemin', 'fonts', 'sass'], function () {
// return gulp.src(publicDir + '/*/**.html')
// .pipe(localScreenshots({
// path: publicDir + '/',
// folder: publicDir + '/img',
// type: 'png',
// suffix: 'shot',
// width: ['1300']
// }))
// .pipe(gulp.dest(publicDir + '/img'));
// });
gulp.task('build', function() {
gulp.start('fonts', 'sass', 'jade', 'uglify', 'imagemin', 'video', 'copy' /*, 'screens'*/);
});
gulp.task('stage', function () {
return gulp.src(['./www/**/*', './data/**/*', './env/stage/CNAME'])
.pipe(deploy());
});
gulp.task('deploy', function () {
if (env != "live" && env != "stage") {
throw Error("Ooops, deployment target is missing. Should be one of '--environment stage' '--environment live'");
}
return gulp.src(['./www/**/*', './data/**/*', environment.cname])
.pipe(deploy(environment.deployOptions));
});
gulp.task('default', ['connect', 'build', 'watch']);