0

I started to build an app using the webapp generator which has been great thanks to the ease of use of grunt coupled with the live reloading of the server. However, I'm at the point that I need to start building a server-side piece that will have requests made against it from the aforementioned client-side app.

At this point I have a basic server.js starting point using Express. Is it possible to gain the live reloading of my static code, SASS recompilation, and have the server-side code be served up through my Express server all on the same host and port?

Kyle Hayes
  • 5,225
  • 8
  • 38
  • 53

1 Answers1

1

It is possible to run the Grunt server on port 9000 (Yeoman default), LiveReload on port 35729 and the Node server on port 3000. As for hosting it all on the same port, you would need to develop your own daemon task to handle all the incoming signals, re-routing them to the individual processes, which is not optimal.

Unless you're going for a specific front-end framework, generator-webapp is great for a starting project. Some tips I would recommend in terms of structuring:

  1. Using the grunt-contrib-jade plugin to compile your HTML to Jade for the use of partials on the server-side.

  2. Re-routing the static folder to app during development and dist for production (in Coffeescript):

app.use express.static(path.join(__dirname, "../app"))

Daniel Li
  • 14,976
  • 6
  • 43
  • 60