Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
1837 views
1
/* global module:false */
2
module.exports = function(grunt) {
3
var port = grunt.option('port') || 8000;
4
var root = grunt.option('root') || '.';
5
6
if (!Array.isArray(root)) root = [root];
7
8
// Project configuration
9
grunt.initConfig({
10
pkg: grunt.file.readJSON('package.json'),
11
meta: {
12
banner:
13
'/*!\n' +
14
' * reveal.js <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd, HH:MM") %>)\n' +
15
' * http://revealjs.com\n' +
16
' * MIT licensed\n' +
17
' *\n' +
18
' * Copyright (C) 2018 Hakim El Hattab, http://hakim.se\n' +
19
' */'
20
},
21
22
qunit: {
23
files: [ 'test/*.html' ]
24
},
25
26
uglify: {
27
options: {
28
banner: '<%= meta.banner %>\n',
29
ie8: true
30
},
31
build: {
32
src: 'js/reveal.js',
33
dest: 'js/reveal.min.js'
34
}
35
},
36
37
sass: {
38
core: {
39
src: 'css/reveal.scss',
40
dest: 'css/reveal.css'
41
},
42
themes: {
43
expand: true,
44
cwd: 'css/theme/source',
45
src: ['*.sass', '*.scss'],
46
dest: 'css/theme',
47
ext: '.css'
48
}
49
},
50
51
autoprefixer: {
52
core: {
53
src: 'css/reveal.css'
54
}
55
},
56
57
cssmin: {
58
options: {
59
compatibility: 'ie9'
60
},
61
compress: {
62
src: 'css/reveal.css',
63
dest: 'css/reveal.min.css'
64
}
65
},
66
67
jshint: {
68
options: {
69
curly: false,
70
eqeqeq: true,
71
immed: true,
72
esnext: true,
73
latedef: 'nofunc',
74
newcap: true,
75
noarg: true,
76
sub: true,
77
undef: true,
78
eqnull: true,
79
browser: true,
80
expr: true,
81
loopfunc: true,
82
globals: {
83
head: false,
84
module: false,
85
console: false,
86
unescape: false,
87
define: false,
88
exports: false
89
}
90
},
91
files: [ 'Gruntfile.js', 'js/reveal.js' ]
92
},
93
94
connect: {
95
server: {
96
options: {
97
port: port,
98
base: root,
99
livereload: true,
100
open: true,
101
useAvailablePort: true
102
}
103
}
104
},
105
106
zip: {
107
bundle: {
108
src: [
109
'index.html',
110
'css/**',
111
'js/**',
112
'lib/**',
113
'images/**',
114
'plugin/**',
115
'**.md'
116
],
117
dest: 'reveal-js-presentation.zip'
118
}
119
},
120
121
watch: {
122
js: {
123
files: [ 'Gruntfile.js', 'js/reveal.js' ],
124
tasks: 'js'
125
},
126
theme: {
127
files: [
128
'css/theme/source/*.sass',
129
'css/theme/source/*.scss',
130
'css/theme/template/*.sass',
131
'css/theme/template/*.scss'
132
],
133
tasks: 'css-themes'
134
},
135
css: {
136
files: [ 'css/reveal.scss' ],
137
tasks: 'css-core'
138
},
139
html: {
140
files: root.map(path => path + '/*.html')
141
},
142
markdown: {
143
files: root.map(path => path + '/*.md')
144
},
145
options: {
146
livereload: true
147
}
148
},
149
150
retire: {
151
js: [ 'js/reveal.js', 'lib/js/*.js', 'plugin/**/*.js' ],
152
node: [ '.' ]
153
}
154
155
});
156
157
// Dependencies
158
grunt.loadNpmTasks( 'grunt-contrib-connect' );
159
grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
160
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
161
grunt.loadNpmTasks( 'grunt-contrib-qunit' );
162
grunt.loadNpmTasks( 'grunt-contrib-uglify' );
163
grunt.loadNpmTasks( 'grunt-contrib-watch' );
164
grunt.loadNpmTasks( 'grunt-autoprefixer' );
165
grunt.loadNpmTasks( 'grunt-retire' );
166
grunt.loadNpmTasks( 'grunt-sass' );
167
grunt.loadNpmTasks( 'grunt-zip' );
168
169
// Default task
170
grunt.registerTask( 'default', [ 'css', 'js' ] );
171
172
// JS task
173
grunt.registerTask( 'js', [ 'jshint', 'uglify', 'qunit' ] );
174
175
// Theme CSS
176
grunt.registerTask( 'css-themes', [ 'sass:themes' ] );
177
178
// Core framework CSS
179
grunt.registerTask( 'css-core', [ 'sass:core', 'autoprefixer', 'cssmin' ] );
180
181
// All CSS
182
grunt.registerTask( 'css', [ 'sass', 'autoprefixer', 'cssmin' ] );
183
184
// Package presentation to archive
185
grunt.registerTask( 'package', [ 'default', 'zip' ] );
186
187
// Serve presentation locally
188
grunt.registerTask( 'serve', [ 'connect', 'watch' ] );
189
190
// Run tests
191
grunt.registerTask( 'test', [ 'jshint', 'qunit' ] );
192
193
};
194
195