Live reloads for Publish
19 Oct 2020
Publish is a great tool to use when writing your own blog – I used it to write this blog. I think Publish is really great, and I love being able to use Swift for my blog posts. But when I was starting up, setting up my own blog, I really missed the possibility of using live reloads. I'm sure this is probably something that will come eventually be baked into the
publish CLI, but at the time of writing it is not included.
When running the local webserver with
publish run you still have to go into the browser and manually reload the page each time you've rebuilt the output directory (⌘+R). But there are a lot of ways you can solve this. A colleague of mine, who is a proficient web developer, tipped me on a node package called
live-server. It does exactly what you expect it to do. To run it you first have to make sure you have Node installed. Then you'll have to run
cd Output npx live-server
<body>, which sets up a socket to a locally running web server.