@@ -170,6 +170,40 @@ module.exports = function (grunt) {
170170 }
171171 } ,
172172
173+ // Debugging with node inspector
174+ 'node-inspector' : {
175+ custom : {
176+ options : {
177+ 'web-host' : 'localhost'
178+ }
179+ }
180+ } ,
181+
182+ // Use nodemon to run server in debug mode with an initial breakpoint
183+ nodemon : {
184+ debug : {
185+ script : 'server.js' ,
186+ options : {
187+ nodeArgs : [ '--debug-brk' ] ,
188+ env : {
189+ PORT : process . env . PORT || 9000
190+ } ,
191+ callback : function ( nodemon ) {
192+ nodemon . on ( 'log' , function ( event ) {
193+ console . log ( event . colour ) ;
194+ } ) ;
195+
196+ // opens browser on initial server start
197+ nodemon . on ( 'config:update' , function ( ) {
198+ setTimeout ( function ( ) {
199+ require ( 'open' ) ( 'http://localhost:8080/debug?port=5858' ) ;
200+ } , 500 ) ;
201+ } ) ;
202+ }
203+ }
204+ }
205+ } ,
206+
173207 // Automatically inject Bower components into the app
174208 'bower-install' : {
175209 app : { < % if ( jade ) { % >
@@ -386,6 +420,15 @@ module.exports = function (grunt) {
386420 'compass'< % } else { % >
387421 'copy:styles' < % } %>
388422 ] ,
423+ debug : {
424+ tasks : [
425+ 'nodemon' ,
426+ 'node-inspector'
427+ ] ,
428+ options : {
429+ logConcurrentOutput : true
430+ }
431+ } ,
389432 dist: [< % if ( coffee ) { % >
390433 'coffee',< % } % > < % if ( compass ) { % >
391434 'compass:dist',< % } else { % >
@@ -465,6 +508,16 @@ module.exports = function (grunt) {
465508 return grunt . task . run ( [ 'build' , 'express:prod' , 'open' , 'express-keepalive' ] ) ;
466509 }
467510
511+ if (target === 'debug') {
512+ return grunt . task . run ( [
513+ 'clean:server' ,
514+ 'bower-install' ,
515+ 'concurrent:server' ,
516+ 'autoprefixer' ,
517+ 'concurrent:debug'
518+ ] ) ;
519+ }
520+
468521 grunt.task.run([
469522 'clean:server',
470523 'bower-install',
0 commit comments