https://github.com/pmlopes/hot-reload
https://github.com/pmlopes/hot-reload
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/pmlopes/hot-reload
- Owner: pmlopes
- License: apache-2.0
- Created: 2017-09-06T14:37:05.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-02-12T09:47:47.000Z (over 8 years ago)
- Last Synced: 2025-08-03T18:04:33.323Z (11 months ago)
- Language: Java
- Size: 36.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# hot-reload
This is a experimental vertx-web handler for hot reload. This handler is used
in the webpack-vertx-plugin but it is not necessary to, you can also use it
independently.
## What's inside?
This module provides 2 handlers in one:
* A `hot-reload` script + backend based either in SSE or pooling
* A static file server (delegates to the official static file server)
### hot-reload script
The script can listen for updates either as a SSE stream or using pooling.
It defaults to SSE as it is supported on modern web browsers but for legacy
it can be configured to perform HTTP pooling.
### static handler
A static handler will be returned using this factory. If there is a
file named `.hot-reload` on the current working directory then the static
handler is configured to not cache both the filesystem and the http responses.
## How to configure?
In your application router you should add the following code:
```java
final Router router = Router.router(vertx);
// development hot reload
router.get().handler(HotReload.create());
...
// Serve the static resources
router.route().handler(StaticHandler.create());
```
When there isn't a file named `.hot-reload` in the current working directory the handler will
be a NO-OP handler and the last will return a unmodified `StaticHandler`.
In your html application you should have:
```html
```
## How it works?
When you start your application you should have the control file in the current working directory e.g.:
```bash
touch .hot-reload
java -jar target/fatjar.jar
```
Navigate to your HTML page where you loaded the script, and after that update the contents
of the reload control file e.g.:
```bash
echo "update!" >> .hot-reload
```
You will notice that a reload is triggered on the browser.