javalin

Javalin hot reload of static files


I configured a static folder to be served by Javalin:

Javalin.create {
   it.addStaticFiles("/public")
}

In Javalin logs I see:

[main] INFO io.javalin.Javalin - Static file handler added:
{urlPathPrefix: "/", path: "/public", location: Location.CLASSPATH}
Resolved path: 'file:///Users/ls/projects/store/build/resources/main/public/'
[main] INFO io.javalin.Javalin - 

Which is fine. Files get served. But every time I change a JS/HTML/CSS file, I need to restart Javalin. Is there any way around this? I just wanted to refresh the browser for the sake of quick development.


Solution

  • You can use an external location (i.e not a "classpath" location) for your static files:

    config.addStaticFiles("/path/to/external/folder", Location.EXTERNAL);
    

    In that case, changes will be picked up without needing a Javalin restart.