Skip to content

Commit eeaf562

Browse files
author
Vilmos Ioo
committed
Refactored app to separate reader and demo. Added bower. Added specific grunt reader task
1 parent 6505ec1 commit eeaf562

22 files changed

+115
-608
lines changed

.bowerrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "app/components"
3+
}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ node_modules
22
dist
33
.tmp
44
.sass-cache
5-
app/bower_components
5+
app/components
66
coverage/
77
.idea

Gruntfile.js

Lines changed: 95 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ module.exports = function (grunt) {
2424
yeoman: {
2525
// Configurable paths
2626
app: 'app',
27-
dist: 'dist'
27+
dist: 'dist',
28+
demo: 'app/demo',
29+
reader: 'app/reader'
2830
},
2931
// Watches files for changes and runs tasks based on the changed files
3032
watch: {
@@ -97,6 +99,15 @@ module.exports = function (grunt) {
9799
},
98100
// Empties folders to start fresh
99101
clean: {
102+
reader: {
103+
files: [{
104+
dot: true,
105+
src: [
106+
'<%= yeoman.reader %>/**/.tmp',
107+
'<%= yeoman.dist %>/reader'
108+
]
109+
}]
110+
},
100111
dist: {
101112
files: [{
102113
dot: true,
@@ -130,12 +141,23 @@ module.exports = function (grunt) {
130141
}
131142
},
132143
cssmin: {
133-
dist: {
144+
demo: {
134145
files: [{
135146
expand: true,
136147
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',
139161
src: [
140162
'**/*.css'
141163
]
@@ -144,27 +166,46 @@ module.exports = function (grunt) {
144166
},
145167
// Compiles Sass to CSS and generates necessary files if requested
146168
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+
}
151175
},
152-
dist: {}
176+
reader: {
177+
options: {
178+
sassDir: '<%= yeoman.reader %>/styles',
179+
cssDir: '<%= yeoman.reader %>/styles/.tmp',
180+
relativeAssets: true
181+
}
182+
}
153183
},
154184
// Renames files for browser caching purposes
155185
rev: {
156-
dist: {
186+
reader: {
157187
files: {
158188
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}'
160197
]
161198
}
162199
}
163200
},
164201
// Run some tasks in parallel to speed up build process
165202
concurrent: {
166-
dist: [
167-
'compass'
203+
reader: [
204+
'compass:reader',
205+
'concat:reader'
206+
],
207+
demo: [
208+
'compass:demo'
168209
]
169210
},
170211
// Reads HTML for usemin blocks to enable smart builds that automatically
@@ -174,53 +215,60 @@ module.exports = function (grunt) {
174215
options: {
175216
dest: '<%= yeoman.dist %>'
176217
},
177-
html: '<%= yeoman.app %>/index.html'
218+
html: '<%= yeoman.demo %>/index.html'
178219
},
179220
// Performs rewrites based on rev and the useminPrepare configuration
180221
usemin: {
181222
options: {
182-
assetsDirs: ['<%= yeoman.dist %>']
223+
assetsDirs: ['<%= yeoman.dist %>/demo']
183224
},
184-
html: ['<%= yeoman.dist %>/{,*/}*.html'],
185-
css: ['<%= yeoman.dist %>/styles/{,*/}*.css']
225+
html: ['<%= yeoman.dist %>/demo/{,*/}*.html'],
226+
css: ['<%= yeoman.dist %>/demo/styles/{,*/}*.css']
186227
},
187228
concat: {
188229
// concatenate all the reader files into a temporary file
189-
server: {
230+
reader: {
190231
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'
195236
]
196237
}
197238
}
198239
},
199240
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+
]
205253
}
206254
}
207255
},
208256
// Copies remaining files to places other tasks can use
209257
copy: {
210-
dist: {
258+
demo: {
211259
files: [{
212260
expand: true,
213261
dot: true,
214-
cwd: '<%= yeoman.app %>',
215-
dest: '<%= yeoman.dist %>',
262+
cwd: '<%= yeoman.demo %>',
263+
dest: '<%= yeoman.dist %>/demo',
216264
src: [
217-
'**/*.html', 'vendor/jquery.min.js'
265+
'**/*.html', 'components/jquery/jquery.min.js'
218266
]
219267
}]
220268
}
221269
},
222270
replace: {
223-
dist: {
271+
reader: {
224272
options: {
225273
patterns:[
226274
{
@@ -230,7 +278,7 @@ module.exports = function (grunt) {
230278
},
231279
{
232280
replacement: function(){
233-
return grunt.file.read('app/styles/.tmp/style.css');
281+
return grunt.file.read('app/reader/styles/.tmp/style.css');
234282
},
235283
match: 'readerStyles',
236284
expression: false
@@ -242,14 +290,8 @@ module.exports = function (grunt) {
242290
{
243291
expand: true,
244292
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/'
253295
}
254296
]
255297
}
@@ -263,6 +305,16 @@ module.exports = function (grunt) {
263305
}
264306
});
265307

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+
266318
grunt.registerTask('serve', function () {
267319
grunt.task.run([
268320
'clean:server',
@@ -295,6 +347,8 @@ module.exports = function (grunt) {
295347
});
296348

297349
grunt.registerTask('build', [
350+
'jshint',// js hint all JS files
351+
'test', // test the application, also transforms sass files
298352
'clean:dist', // delete dist directory and all its contents
299353
'useminPrepare', // prepare configuration for concat and uglify
300354
'concat', // concatenate JS files in one, move result in .tmp
@@ -307,8 +361,6 @@ module.exports = function (grunt) {
307361
]);
308362

309363
grunt.registerTask('default', [
310-
'jshint',// js hint all JS files
311-
'test',
312364
'build'
313365
]);
314366
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)