Compare commits

..

1 Commits

Author SHA1 Message Date
Simon C
c342d922a7 feat: Add livereload 2024-08-08 00:43:30 +02:00

View File

@ -15,6 +15,7 @@ fn not_htmx_predicate<T>(req: &Request<T>) -> bool {
async fn main() {
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let assets_path = Path::new(&manifest_dir).join("assets");
let templates_path = Path::new(&manifest_dir).join("templates");
let livereload = LiveReloadLayer::new();
let reloader = livereload.reloader();
@ -22,7 +23,7 @@ async fn main() {
let router = get_router(assets_path.as_path()).layer(livereload.request_predicate(not_htmx_predicate));
let mut watcher = notify::recommended_watcher(move |_| reloader.reload()).unwrap();
watcher.watch(&Path::new(&manifest_dir).join("templates"), notify::RecursiveMode::Recursive).unwrap();
watcher.watch(&templates_path, notify::RecursiveMode::Recursive).unwrap();
let mut listenfd = ListenFd::from_env();
let listener = match listenfd.take_tcp_listener(0).unwrap() {