Skip to content

Instantly share code, notes, and snippets.

@colelawrence
Last active August 29, 2015 14:02
Show Gist options
  • Save colelawrence/173e0ad2062676bf73ef to your computer and use it in GitHub Desktop.
Save colelawrence/173e0ad2062676bf73ef to your computer and use it in GitHub Desktop.
Nodemon and devreload for debugging web applications
doctype html
html
head
title= title
link(rel='stylesheet' href='/vendors/bootstrap-3.1.1/bootstrap.min.css')
link(rel='stylesheet' href='/css/style.css')
link(rel='stylesheet' href='/css/helpers.css')
block head
body
block content
footer
script(src="http://localhost:9999/devreload.js")
script(src="/vendors/jquery-2.1.1/jquery-2.1.1.min.js")
block footer
# This is for development purposes
devreload = require 'devreload'
ndm = require 'nodemon'
p = require 'path'
if devreload
# Use devreload for reloading the browser
try
devreload.listen {watch:null, port:9999}
catch e
devreload = null
willWatchStatic = '--static' in process.argv or '--all' in process.argv
willWatchVend = '--vendors' in process.argv or '--all' in process.argv
willWatchGraphics = '--graphics' in process.argv or '--all' in process.argv
start = ->
ext = 'jade coffee js'
watch = ['routes/','lib/','views/','app.js']
if willWatchVend
watch.push 'static/vendors/'
ext += ' css'
if willWatchStatic
watch.push 'static/js'
watch.push 'static/styl'
ext += ' styl'
if willWatchGraphics
watch.push 'static/graphics'
ext += ' jpg png svg gif'
ndm {
script: 'bin/www'
watch
ext
}
.on 'restart', ->
devreload.reload() if devreload
.on 'log', (log) ->
console.log log.colour
start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment