package dream-html
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=a7326b67750b7658283235f5c2b8483f7633785d0e4e8060f8745353edb925b1
sha512=74c10a8b55b5c90fd1b87cf4ce9ed8af6a514a4d56d874b219207ff75316cbcdebb8aefe6b4fb858d46eaa2374fe289b7ce4885ca17d9e6052b46d4842da43c7
doc/dream-html/Dream_html/Livereload/index.html
Module Dream_html.Livereload
Source
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.
(1) Put this in your top-level router:
let () = Dream.run
@@ Dream.logger
@@ Dream.router [
Dream_html.Livereload.route;
(* ...other routes... *)
]
(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.