0.1.1 |
|
---|---|
0.1.0 |
|
#8 in #reloading
9KB
105 lines
Liver
Quick and dirty live reloading server for web development.
Documentation
See docs.rs for how to use Liver.
License
This project is licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
lib.rs
:
Liver
Quick and dirty live reloading server for web development.
This library provides one function watch
that does the following:
- Creates a WebSocket server (with [
ws
]). - Creates a file watcher (with
hotwatch
) that detects file changes and sends a WebSocket message whenever one happens. - Creates a small HTTP server (with
rocket
) that returns static files from the path you passed throughwatch
. And it injects some JavaScript in any HTML files to reload the page when a WebSocket message is received.
Note: this was developed in a very quick and dirty manner, please don't
use this in a production setting. It doesn't have proper error handling
(unwrap
s everywhere) and isn't thoroughly tested. If you're interested in
improving the code and stability, I very much welcome it. I think I've
gotten about as far as I can with my limited Rust capabilities.
To change the ports used for Rocket or the WebSocket server, you can set
their corresponding environment variables: ROCKET_PORT
(8000 by default)
and WS_PORT
(8001 by default).
Dependencies
~11–20MB
~302K SLoC