-
Notifications
You must be signed in to change notification settings - Fork 0
/
GulpFile.js
152 lines (134 loc) · 3.83 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
'use strict';
var gulp = require('gulp');
var header = require('gulp-header');
var pkg = require('./package.json');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var qunit = require('gulp-qunit');
var cssmin = require('gulp-cssmin');
var sass = require('gulp-sass');
var jshint = require('gulp-jshint');
var connect = require('gulp-connect');
var zip = require('gulp-zip');
var paths = {
docs: './docs',
css: [
'css/reveal.min.css',
'css/**/solarized.css',
'lib/css/zenburn.css',
'css/**/pdf.css'
],
imgs: [
'img/*.jpg',
'img/*.png'
],
js: [
'js/reveal.min.js',
'lib/js/head.min.js',
'lib/js/html5shiv.js'
],
html: 'index.html',
};
var banner = ['/*!\n',
' * reveal.js <%= pkg.version %> (<%= now() %>)\n',
' * http://lab.hakim.se/reveal-js\n',
' * MIT licensed\n',
' *\n',
' * Copyright (C) 2014 Hakim El Hattab, http://hakim.se\n',
' */',
'\n'].join('');
var serverConfig = {
root: './',
livereload: true,
port : 8000
};
gulp.task('qunit', function() {
return gulp.src('test/*.html')
.pipe(qunit());
});
gulp.task('uglify', function() {
gulp.src('js/reveal.js')
.pipe(uglify())
.pipe(rename('reveal.min.js'))
.pipe(header(banner, {
pkg : pkg,
now: function () {
var d = new Date();
var date = d.getDate() < 10 ? '0'+d.getDate() : d.getDate();
var month = d.getMonth() < 9 ? '0'+ (d.getMonth() + 1) : (d.getMonth() + 1);
var year = d.getFullYear();
var hours = d.getHours() < 10 ? '0'+d.getHours() : d.getHours();
var mins = d.getMinutes();
return (year+'-'+month+'-'+date+', '+hours+':'+mins);
}
}))
.pipe(gulp.dest('js'));
});
gulp.task('cssmin', function () {
gulp.src('css/reveal.css')
.pipe(cssmin())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('css'));
});
gulp.task('sass', function () {
gulp.src('css/theme/source/*.scss')
.pipe(sass())
.pipe(gulp.dest('css/theme'));
});
gulp.task('jshint', function() {
return gulp.src([ 'gulpFile.js', 'js/reveal.js' ])
.pipe(jshint({
curly: false,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
eqnull: true,
browser: true,
expr: true,
globals: {
head: false,
module: false,
console: false,
unescape: false
}
}))
.pipe(jshint.reporter('default'));
});
gulp.task('connect', function() {
connect.server(serverConfig);
});
gulp.task('html', function () {
gulp.src('index.html')
.pipe(connect.reload());
});
gulp.task('zip', function () {
return gulp.src([
'index.html',
'css/**',
'js/**',
'lib/**',
'images/**',
'plugin/**'
], {base: "."})
.pipe(zip('reveal-js-presentation.zip'))
.pipe(gulp.dest('./'));
});
gulp.task('watch', function () {
gulp.watch([ 'gulpFile.js', 'js/reveal.js', 'css/reveal.css' ], ['themes','html']);
gulp.watch([ 'css/theme/source/*.scss', 'css/theme/template/*.scss' ], ['themes']);
gulp.watch(['index.html'], ['html'])
});
// Default task
gulp.task( 'default', [ 'jshint', 'cssmin', 'uglify', 'qunit' ] );
// Theme task
gulp.task( 'themes', [ 'sass' ] );
// Package presentation to archive
gulp.task( 'package', [ 'default', 'zip' ] );
// Serve presentation locally
gulp.task( 'serve', [ 'connect', 'watch' ] );
// Run tests
gulp.task( 'test', [ 'jshint', 'qunit' ] );