A simple, no-nonsense, hot-reloading web server for local static site development.
Toil is something I built in a day to solve this problem for myself. It's never going to be much cleverer than it already is. You may use it at your own risk.
It supports regular old static file structures โ
localhost:3456/page/index.html
...but also pretty URLs โ
localhost:3456/page
If those files change on disk, it will hot-reload them. It polls once every second so as not to unduly waste resources.
With appropriate firewall permissions, it can serve as many clients as you like (within reason).
With the Go compiler โ
go install github.com/lichendust/toil@latest
toil
Will immediately begin serving and hot-loading the working directory. It will also, on startup, open your default browser to the index.html page it finds there.
toil path/to/files
You can optionally pass a path, to serve a specific folder. Toil just changes directories internally and starts normally.
Use Ctrl+C to close it.
Use the -r flag to specific a domain to replace with local paths.
toil -r https://lichendust.com path/to/files
This will strip out the exact string from any pages Toil serves, a simple way to make links relative in locally served pages that otherwise contain fully qualified URLs. Useful for SSGs that don't have their own servers.
Toil expects properly formatted HTML files with at least a <head> and <body>. It will insert its client-side hot-reload listener into the <head>. There must be a head already for this to work. Toil is not a smart server and will not solve any incompletely-formatted HTML documents for you.