package dream-html
-
dream-html
Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
Live reload script injection and handling. Adapted from Dream.livereload
middleware. This version is not a middleware so it's not as plug-and-play as that, but on the other hand it's much simpler to implement because it uses type-safe dream-html nodes rather than parsing and printing raw HTML. See below for the 3-step process to use it.
This module is adapted from Dream, released under the MIT license. For details, visit https://github.com/aantron/dream.
Copyright 2021-2023 Thibaut Mattio, Anton Bachin.
val route : Dream.route
(1) Put this in your top-level router:
let () = Dream.run
@@ Dream.logger
@@ Dream.router [
Dream_html.Livereload.route;
(* ...other routes... *)
]
val script : node
(2) Put this inside your head
:
head [] [
Livereload.script;
(* ... *)
]
(3) And run the server with environment variable LIVERELOAD=1
.
⚠️ If this env var is not set, then livereload is turned off. This means that the route
will respond with 404
status and the script will be omitted from the rendered HTML.