After looking around and not finding a proper answer (the closest and kind of incomplete is this: Grunt livereload with node.js application), I decided to ask.
Given:
node app, client + server (with express)
Desired:
- ability to start the above app using
node-dev
orsupervisor
so that changes to server files reload the server - ability to configure grunt-contrib-watch, so that changes to client files reload the browser
- unless it was clear from the above - both server and client are deployed with the same express server
Issues & Attempts
Despite trying various permutations of watch, connect, parallel, concurrent and more, the main issue remains - inability to inject livereload
script into the same domain:port
express started on.
Obviously I can configure all REST and socket calls from client to server so that they use some sort of prefix during development and deploy client and server on different ports on `127.0.0.1' or some other stuff like that, while changing it in production to be the same server.
Please look at following example to add files information to be watched:
As per issue you have mention i.e. inability to inject livereload script, I think it is an issue related with connect configuration. Now grunt-contrib-livereload is deprecated and now include in watch, so might be liverealod snippet code is creating an issue here. So please try below code, I implement this in one of my project using yeoman.
I wish this could help you. Thanks