Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ybonnel/vertx-livereload
A simple livereload server for vertx application
https://github.com/ybonnel/vertx-livereload
Last synced: 3 months ago
JSON representation
A simple livereload server for vertx application
- Host: GitHub
- URL: https://github.com/ybonnel/vertx-livereload
- Owner: ybonnel
- Created: 2018-03-19T20:36:05.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-20T09:27:53.000Z (almost 7 years ago)
- Last Synced: 2024-08-04T01:08:54.067Z (6 months ago)
- Language: JavaScript
- Size: 1020 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- vertx-awesome - Vert.x LiveReload - A simple livereload server for Vert.x applications. (Development Tools)
README
# Vertx-livereload
A very simple helper to have a [livereload](http://livereload.com/) server on a vertx application for your static resources.
## Motivation
Refresh a web page can be so long :), so just save your js/css/html file and when you arrived in you browser the change is already there.
## Implementation
All samples are in kotlin, but it's very simple, so the conversion to java must be easy.
Image you avec some static resources :
```kotlin
get("/public/*").handler(
StaticHandler.create("src/main/resources/public")
.setCachingEnabled(false)
)
```this is just the dev example, in real life you may have something like that :
```kotlin
if (getMode() == "dev") {
get("/public/*").handler(
StaticHandler.create("src/main/resources/public")
.setCachingEnabled(false)
)
} else {
get("/public/*").handler(StaticHandler.create("public"))
}
```Why not just the "prod mode" code? Because I don't want to wait the compile process to have my update :)
So, as you guess, I have some static files in ```src/main/resources/public``` which are served for url ```/public/*```
Now to add my livereload, I just add this code to my verticle :```kotlin
import fr.ybonnel.vertx.livereload.LiveReloadclass MainVerticle: AbstractVerticle() {
private lateinit var liveReloadServer: LiveReloadoverride fun start(startFuture: Future) {
/* ... */
liveReloadServer = LiveReload(this.vertx, mapOf(
"src/main/resources/public/" to "/public/"
))
liveReloadServer?.start()?.setHandler(startFuture)
}override fun stop(stopFuture: Future) {
/* ... */
liveReloadServer?.stop()?.setHandler(stopFuture)
}
}
```## Demo
![Demo](https://github.com/ybonnel/vertx-livereload/raw/master/vertx-livereload.gif)
## How to install
The artifact is published to bintray : [bintray.com/ybonnel/maven/vertx-livereload](https://bintray.com/ybonnel/maven/vertx-livereload)