-->

Clojure live browser reload on Linux

2020-07-13 09:13发布

问题:

Is there something like Rack-LiveReload that could be used along with a tool like Guard-LiveReload for Clojure development? I really cannot make do without live reloading now that I have used it. If there is nothing more convenient I could download the LiveReload JS file and manually include it in my app and use that with Guard-LiveReload, but I would prefer it if there was an all Clojure solution. I cannot install the LiveReload app on my machine because I am using Linux, so that is why I would need something like Guard-LiveReload.

I am new to Clojure, but so far I am going to go with Ring and Compojure, which perhaps might make a difference.

回答1:

OK, this can be done very easily, but with Grunt and https://github.com/gruntjs/grunt-contrib-watch (which has built in LiveReload support), Grunt will work with any language.



回答2:

I was poking around the c2 library and discovered the author created a liverelaod server in Clojure.

https://github.com/lynaghk/c2/tree/master/vrepl

He also has a screencast on his website. http://keminglabs.com/c2/

Grunt will probably work for you, but since you asked about a Clojure implementation I thought I would mention it.



回答3:

Imho the best and idiomatic way to go in your case could be to migrate from Ring Jetty adapter to http-kit which provides hot code reload out of the box. It also supports Websockets and it has a noticeable performance

Of course it's compatible with Ring & Compojure: HTTP Kit is a minimalist, efficient, Ring-compatible HTTP client/server for Clojure. It uses a event-driven architecture to support highly concurrent a/synchronous web applications. Feature a unified API for WebSocket and HTTP long polling/streaming