I'm looking for an HTTP server that can be invoked from the command line for localhost. I want it to be able to watch static html and css files for changes and reload the page viewed in a browser when changes are noticed.

I've found a number of nodejs packages filling this task, but many of them don't work well. Here are the nodejs packages I tried:

live-server is doing it good for the default default.html and index.html pages. If I want to watch an HTML page which is not index.html or default.html, I don't see the browser actually updates.

fast-live-reload perhaps is not suited for static web pages and only for web applications of some sort.

livereload just doesn't work at all, perhaps it is not suited for static web pages and only for web applications as well

EDIT

nginx is an overkill.

webpack-dev-server seems like is good choice only for people who work with the webpack JS framework. I tried it with webpack-dev-server . and it gives me the following errors:

While searching the internet, it seemed that most of these packages are not meant for static and plain HTML and CSS web pages. I'm not a web applications developer. I just want to write plain HTML and CSS and that's all.

Well, the only way to do this with HTML pages only and no specific server support is to have the page regularly reload itself on a timer and configure the page so it is not cached by the browser (probably with <meta> tags). Any sort of smart reload that only reloads when the page actually changes on the server will need custom server support for that and will likely need a persistent webSocket connection from web page to server to the browser can be told by the server when to fetch updated content.
– jfriend00Dec 13 '17 at 17:00

2 Answers
2

Mongoose: A small, single executable, embeddable server <- but you'd need to check if it can notice changes to the static files

Use the Python webserver module (i.e. python -m http.server <PORT>) - assuming you can configure it to do what you want

thttpd : A nother very small server; it's man page says it monitors the configuration file for changes, so chances are it also monitors the served files for changes (or simply doesn't cache a copy of them).

nginx or lighttpd: Possibly overkill in terms of features, but nginx is modular and both have small footprints, supposedly.

First of all, yes, I want it only for pure HTML,CSS and JS. Additionally, I tried webpack-dev-server and I get lot's of errors about unfound modules. I edited the original post.
– Doron BeharDec 15 '17 at 19:47

... Did you run npm install? Getting started with npm/node can be a bit of work at first - as there are a few dependencies that you need to use first. Did you try my github project?
– dwjohnstonDec 15 '17 at 21:16

Of course I did, I installed webpack and webpack-dev-server with npm install -g.
– Doron BeharDec 20 '17 at 17:37