11/* jshint node: true */
2+ var path = require ( 'path' ) ;
3+ var docsFolderMount = function folderMount ( connect , point ) {
4+ return connect . static ( path . resolve ( point + '/_gh_pages/' ) ) ;
5+ } ;
26
37module . exports = function ( grunt ) {
48 "use strict" ;
59
10+ var modules = {
11+ self : this ,
12+ grunt : grunt
13+ } ;
14+
15+ modules . livereload = require ( './assets/js/grunts/livereload' ) ( modules ) ;
16+
617 // Project configuration.
718 grunt . initConfig ( {
819
@@ -23,16 +34,22 @@ module.exports = function(grunt) {
2334 } ,
2435
2536 jshint : {
26- options : {
27- jshintrc : 'js/.jshintrc'
28- } ,
29- gruntfile : {
30- src : 'Gruntfile.js'
31- } ,
32- src : {
37+ plugins : {
38+ options : {
39+ jshintrc : 'js/.jshintrc'
40+ } ,
3341 src : [ 'js/*.js' ]
3442 } ,
43+ assets : {
44+ options : {
45+ jshintrc : 'js/.jshintrc'
46+ } ,
47+ src : [ 'assets/js/application.js' ]
48+ } ,
3549 test : {
50+ options : {
51+ jshintrc : 'js/.jshintrc'
52+ } ,
3653 src : [ 'js/tests/unit/*.js' ]
3754 }
3855 } ,
@@ -83,7 +100,7 @@ module.exports = function(grunt) {
83100 options : {
84101 config : 'config.rb' ,
85102 environment : 'production' ,
86- force : grunt . option ( 'force' ) || false
103+ force : grunt . option ( 'force' ) || true
87104 }
88105 }
89106 } ,
@@ -115,11 +132,21 @@ module.exports = function(grunt) {
115132 } ,
116133
117134 connect : {
118- server : {
135+ test : {
119136 options : {
120- port : 9003 ,
137+ port : 3000 ,
121138 base : '.'
122139 }
140+ } ,
141+ // docs server
142+ docs : {
143+ options : {
144+ port : 9001 ,
145+ hostname : '0.0.0.0' ,
146+ middleware : function ( connect , options ) {
147+ return [ docsFolderMount ( connect , options . base ) ] ;
148+ }
149+ }
123150 }
124151 } ,
125152
@@ -137,17 +164,57 @@ module.exports = function(grunt) {
137164 } ,
138165
139166 watch : {
140- src : {
141- files : '<%= jshint.src.src %>' ,
142- tasks : [ 'jshint:src' , 'qunit' ]
167+ plugins : {
168+ files : '<%= jshint.plugins.src %>' ,
169+ tasks : [ 'jshint:plugins' , 'qunit' ] ,
170+ options : {
171+ livereload : true
172+ }
173+ } ,
174+ docsjs : {
175+ files : '<%= jshint.assets.src %>' ,
176+ tasks : [ 'jshint:assets' ] ,
177+ options : {
178+ livereload : true
179+ }
143180 } ,
144181 test : {
145182 files : '<%= jshint.test.src %>' ,
146- tasks : [ 'jshint:test' , 'qunit' ]
183+ tasks : [ 'jshint:test' , 'qunit' ] ,
184+ options : {
185+ livereload : true
186+ }
147187 } ,
148- css : {
188+ scss : {
149189 files : [ 'sass/*.scss' , 'sass/*/*.scss' ] ,
150- tasks : [ 'compass:bootstrap' ]
190+ tasks : [ 'compass:bootstrap' ] ,
191+ options : {
192+ // no need for this because the compile that occurs in compass
193+ // will update the css files that are being watched by the watch:html task
194+ livereload : false
195+ }
196+ } ,
197+ assets : {
198+ files : [ 'assets/**/*' ] ,
199+ tasks : [ 'jekyll:docs' ] ,
200+ options : {
201+ livereload : true
202+ }
203+ } ,
204+ html : {
205+ files : [
206+ // must watch here to trigger jekyll when compass finishes compiling
207+ 'dist/**/*.css' ,
208+ 'fonts/**/*' ,
209+ 'js/**/*' ,
210+ '**/*.html' ,
211+ '!_gh_pages/**/*' ,
212+ '!submodules/**/*'
213+ ] ,
214+ tasks : [ 'jekyll:docs' ] ,
215+ options : {
216+ livereload : true
217+ }
151218 }
152219 }
153220 } ) ;
@@ -167,12 +234,14 @@ module.exports = function(grunt) {
167234 grunt . loadNpmTasks ( 'grunt-html-validation' ) ;
168235 grunt . loadNpmTasks ( 'grunt-jekyll' ) ;
169236
237+ grunt . registerTask ( 'lr' , modules . livereload ) ;
238+
170239 // Docs HTML validation task
171240 grunt . registerTask ( 'validate-html' , [ 'jekyll' , 'validation' ] ) ;
172241
173242 // Test task.
174243 grunt . registerTask ( 'testSubtasks' , [ 'jshint' , 'qunit' , 'validate-html' ] ) ;
175- grunt . registerTask ( 'testSubtasksNoValidation' , [ 'jshint' , 'qunit' , 'jekyll' ] ) ;
244+ grunt . registerTask ( 'testSubtasksNoValidation' , [ 'jshint' , 'qunit' ] ) ;
176245 grunt . registerTask ( 'test' ,
177246 function ( ) {
178247 if ( grunt . option ( 'validate' ) ) {
@@ -188,14 +257,29 @@ module.exports = function(grunt) {
188257
189258 // CSS distribution task.
190259 grunt . registerTask ( 'dist-css' , [ 'compass:bootstrap' ] ) ;
260+ grunt . registerTask ( 'dist-css-min' , [ 'compass:min' ] ) ;
191261
192262 // Fonts distribution task.
193263 grunt . registerTask ( 'dist-fonts' , [ 'copy:fonts' ] ) ;
194264
195265 // Full distribution task.
196- grunt . registerTask ( 'dist' , [ 'clean' , 'dist-fonts' , 'dist-css' , 'dist-js' , 'compress:dist' ] ) ;
266+ grunt . registerTask ( 'dist' , [ 'clean' , 'dist-fonts' , 'dist-css-min ' , 'dist-js' , 'compress:dist' ] ) ;
197267
198268 // Default task.
199269 grunt . registerTask ( 'default' , [ 'test' , 'dist' ] ) ;
200270
271+ // Default task that runs jekyll server, delivers uncompressed css and watch capabilities
272+ grunt . registerTask ( 'dev' ,
273+ [
274+ 'lr' ,
275+ 'connect:docs' ,
276+ 'dist-fonts' ,
277+ 'dist-css' ,
278+ 'test' ,
279+ 'dist-js' ,
280+ 'compress:dist' ,
281+ 'watch'
282+ ]
283+ ) ;
284+
201285} ;
0 commit comments