-2

I am new to node or grunt. I have developed a website using html, css and bootstrap. Now I am confused how to run this site? shall I use nodejs to serve static files or use grunt?

Most of the examples I see use grunt-watch and grunt-serve to serve files. Is watching a file necessary only during development phase and not in production right?

I would also like to minify the files(css,js etc) before I host it. I am from java background where I normally use apache tomcat to deploy and run a webapp, but just for static site I don't want to use tomcat server. How do I go about this?

Note: I am trying to deploy my project on heroku.

kittu
  • 6,662
  • 21
  • 91
  • 185

2 Answers2

-1

As an addition to T.J. Crowder anwer

To serve static html app

npm install -g http-server
http-server ./index.html

To serve nodejs app

npm install -g forever
forever start server.js

To develop static app

//grunt or gulp
//both support watchers, livereaload, minifications, bundling
//google it

To develop nodejs app

express
hapi
meanjs
...many other
Community
  • 1
  • 1
Medet Tleukabiluly
  • 11,662
  • 3
  • 34
  • 69
  • As you have mentioned in your last point "To develop nodejs app" to use express and I guess I have already mentioned in my answer using expressjs which can be run locally or when deployed on heroku – kittu Jun 19 '16 at 14:39
-2

Finally got my answer:

Used express js to serve static files

use npm install express --save -dev

and then in the index.js or server.js file:

var express = require('express');
var app = express();

app.set('port', (process.env.PORT || 5000));

app.use(express.static(__dirname + '/public'));

app.get('/', function(request, response) {
  response.render('public/');
});

app.listen(app.get('port'), function() {
  console.log('Node app is running on port', app.get('port'));
});

So the above line app.use(express.static(__dirname + '/public')); will serve static files like html,css etc from this folder (i.e public)

and then in the command prompt: node index.js will start the server

kittu
  • 6,662
  • 21
  • 91
  • 185