@@ -24,7 +24,9 @@ module.exports = function (grunt) {
24
24
yeoman : {
25
25
// Configurable paths
26
26
app : 'app' ,
27
- dist : 'dist'
27
+ dist : 'dist' ,
28
+ demo : 'app/demo' ,
29
+ reader : 'app/reader'
28
30
} ,
29
31
// Watches files for changes and runs tasks based on the changed files
30
32
watch : {
@@ -97,6 +99,15 @@ module.exports = function (grunt) {
97
99
} ,
98
100
// Empties folders to start fresh
99
101
clean : {
102
+ reader : {
103
+ files : [ {
104
+ dot : true ,
105
+ src : [
106
+ '<%= yeoman.reader %>/**/.tmp' ,
107
+ '<%= yeoman.dist %>/reader'
108
+ ]
109
+ } ]
110
+ } ,
100
111
dist : {
101
112
files : [ {
102
113
dot : true ,
@@ -130,12 +141,23 @@ module.exports = function (grunt) {
130
141
}
131
142
} ,
132
143
cssmin : {
133
- dist : {
144
+ demo : {
134
145
files : [ {
135
146
expand : true ,
136
147
dot : true ,
137
- cwd : '<%= yeoman.app %>/styles/.tmp' ,
138
- dest : '<%= yeoman.app %>/styles/.tmp' ,
148
+ cwd : '<%= yeoman.demo %>/styles/.tmp' ,
149
+ dest : '<%= yeoman.demo %>/styles/.tmp' ,
150
+ src : [
151
+ '**/*.css'
152
+ ]
153
+ } ]
154
+ } ,
155
+ reader : {
156
+ files : [ {
157
+ expand : true ,
158
+ dot : true ,
159
+ cwd : '<%= yeoman.reader %>/styles/.tmp' ,
160
+ dest : '<%= yeoman.reader %>/styles/.tmp' ,
139
161
src : [
140
162
'**/*.css'
141
163
]
@@ -144,27 +166,46 @@ module.exports = function (grunt) {
144
166
} ,
145
167
// Compiles Sass to CSS and generates necessary files if requested
146
168
compass : {
147
- options : {
148
- sassDir : '<%= yeoman.app %>/styles' ,
149
- cssDir : '<%= yeoman.app %>/styles/.tmp' ,
150
- relativeAssets : true
169
+ demo : {
170
+ options : {
171
+ sassDir : '<%= yeoman.demo %>/styles' ,
172
+ cssDir : '<%= yeoman.demo %>/styles/.tmp' ,
173
+ relativeAssets : true
174
+ }
151
175
} ,
152
- dist : { }
176
+ reader : {
177
+ options : {
178
+ sassDir : '<%= yeoman.reader %>/styles' ,
179
+ cssDir : '<%= yeoman.reader %>/styles/.tmp' ,
180
+ relativeAssets : true
181
+ }
182
+ }
153
183
} ,
154
184
// Renames files for browser caching purposes
155
185
rev : {
156
- dist : {
186
+ reader : {
157
187
files : {
158
188
src : [
159
- '<%= yeoman.dist %>/**/*.{js,css}'
189
+ '<%= yeoman.dist %>/reader/**/*.{js,css}'
190
+ ]
191
+ }
192
+ } ,
193
+ demo : {
194
+ files : {
195
+ src : [
196
+ '<%= yeoman.dist %>/demo/**/*.{js,css}'
160
197
]
161
198
}
162
199
}
163
200
} ,
164
201
// Run some tasks in parallel to speed up build process
165
202
concurrent : {
166
- dist : [
167
- 'compass'
203
+ reader : [
204
+ 'compass:reader' ,
205
+ 'concat:reader'
206
+ ] ,
207
+ demo : [
208
+ 'compass:demo'
168
209
]
169
210
} ,
170
211
// Reads HTML for usemin blocks to enable smart builds that automatically
@@ -174,53 +215,60 @@ module.exports = function (grunt) {
174
215
options : {
175
216
dest : '<%= yeoman.dist %>'
176
217
} ,
177
- html : '<%= yeoman.app %>/index.html'
218
+ html : '<%= yeoman.demo %>/index.html'
178
219
} ,
179
220
// Performs rewrites based on rev and the useminPrepare configuration
180
221
usemin : {
181
222
options : {
182
- assetsDirs : [ '<%= yeoman.dist %>' ]
223
+ assetsDirs : [ '<%= yeoman.dist %>/demo ' ]
183
224
} ,
184
- html : [ '<%= yeoman.dist %>/{,*/}*.html' ] ,
185
- css : [ '<%= yeoman.dist %>/styles/{,*/}*.css' ]
225
+ html : [ '<%= yeoman.dist %>/demo/ {,*/}*.html' ] ,
226
+ css : [ '<%= yeoman.dist %>/demo/ styles/{,*/}*.css' ]
186
227
} ,
187
228
concat : {
188
229
// concatenate all the reader files into a temporary file
189
- server : {
230
+ reader : {
190
231
files : {
191
- '<%= yeoman.app %>/scripts/.tmp/reader.js' : [
192
- '<%= yeoman.app %>/vendor /epubcfi.min.js' ,
193
- '<%= yeoman.app %>/vendor /bugsense.js' ,
194
- '<%= yeoman.app %>/scripts/** /*.js'
232
+ '<%= yeoman.reader %>/scripts/.tmp/reader.js' : [
233
+ '<%= yeoman.app %>/lib /epubcfi.min.js' ,
234
+ '<%= yeoman.app %>/components/bugsense /bugsense.js' ,
235
+ '<%= yeoman.reader %>/scripts/*.js'
195
236
]
196
237
}
197
238
}
198
239
} ,
199
240
uglify :{
200
- options : {
201
- // this workaround is required to make uglifyjs ignore escaped characters from epbcfi library
202
- beautify : {
203
- ascii_only : true ,
204
- beautify : false
241
+ reader : {
242
+ options : {
243
+ // this workaround is required to make uglifyjs ignore escaped characters from epbcfi library
244
+ beautify : {
245
+ ascii_only : true ,
246
+ beautify : false
247
+ }
248
+ } ,
249
+ files : {
250
+ '<%= yeoman.dist %>/reader/reader.min.js' : [
251
+ '<%= yeoman.reader %>/scripts/.tmp/reader.js'
252
+ ]
205
253
}
206
254
}
207
255
} ,
208
256
// Copies remaining files to places other tasks can use
209
257
copy : {
210
- dist : {
258
+ demo : {
211
259
files : [ {
212
260
expand : true ,
213
261
dot : true ,
214
- cwd : '<%= yeoman.app %>' ,
215
- dest : '<%= yeoman.dist %>' ,
262
+ cwd : '<%= yeoman.demo %>' ,
263
+ dest : '<%= yeoman.dist %>/demo ' ,
216
264
src : [
217
- '**/*.html' , 'vendor /jquery.min.js'
265
+ '**/*.html' , 'components/jquery /jquery.min.js'
218
266
]
219
267
} ]
220
268
}
221
269
} ,
222
270
replace : {
223
- dist : {
271
+ reader : {
224
272
options : {
225
273
patterns :[
226
274
{
@@ -230,7 +278,7 @@ module.exports = function (grunt) {
230
278
} ,
231
279
{
232
280
replacement : function ( ) {
233
- return grunt . file . read ( 'app/styles/.tmp/style.css' ) ;
281
+ return grunt . file . read ( 'app/reader/ styles/.tmp/style.css' ) ;
234
282
} ,
235
283
match : 'readerStyles' ,
236
284
expression : false
@@ -242,14 +290,8 @@ module.exports = function (grunt) {
242
290
{
243
291
expand : true ,
244
292
flatten : true ,
245
- src : [ '<%= yeoman.app %>/scripts/.tmp/*.js' ] ,
246
- dest : '<%= yeoman.app %>/scripts/.tmp/'
247
- } ,
248
- {
249
- expand : true ,
250
- flatten : true ,
251
- src : [ '.tmp/concat/**/*.js' ] ,
252
- dest : '.tmp/concat/'
293
+ src : [ '<%= yeoman.reader %>/scripts/.tmp/*.js' ] ,
294
+ dest : '<%= yeoman.reader %>/scripts/.tmp/'
253
295
}
254
296
]
255
297
}
@@ -263,6 +305,16 @@ module.exports = function (grunt) {
263
305
}
264
306
} ) ;
265
307
308
+ grunt . registerTask ( 'reader' , function ( ) {
309
+ grunt . task . run ( [
310
+ 'clean:reader' ,
311
+ 'concurrent:reader' ,
312
+ 'cssmin:reader' ,
313
+ 'replace:reader' ,
314
+ 'uglify:reader'
315
+ ] ) ;
316
+ } ) ;
317
+
266
318
grunt . registerTask ( 'serve' , function ( ) {
267
319
grunt . task . run ( [
268
320
'clean:server' ,
@@ -295,6 +347,8 @@ module.exports = function (grunt) {
295
347
} ) ;
296
348
297
349
grunt . registerTask ( 'build' , [
350
+ 'jshint' , // js hint all JS files
351
+ 'test' , // test the application, also transforms sass files
298
352
'clean:dist' , // delete dist directory and all its contents
299
353
'useminPrepare' , // prepare configuration for concat and uglify
300
354
'concat' , // concatenate JS files in one, move result in .tmp
@@ -307,8 +361,6 @@ module.exports = function (grunt) {
307
361
] ) ;
308
362
309
363
grunt . registerTask ( 'default' , [
310
- 'jshint' , // js hint all JS files
311
- 'test' ,
312
364
'build'
313
365
] ) ;
314
366
} ;
0 commit comments