feat: Add liveReload#1407
Conversation
|
To be decided: Should clients try to reconnect to the server, e.g. in case it has been restarted? This is currently not implemented, but I think it should be added. |
This has now been implemented. |
ff657e6 to
409ab00
Compare
Adds optional live reload support to the server: - New `serveLiveReloadClient` middleware serves the client at `/.ui5/liveReload/client.js`. - The `serveResources` middleware injects the client script tag into HTML responses when `liveReload` is enabled. - A WebSocket server attaches to the HTTP server and notifies connected clients when the BuildServer emits a `sourcesChanged` event. The feature is opt-in via the new `liveReload` option to `serve()` and defaults to `false`. JIRA: CPOUI5FOUNDATION-1224
- Add new `server.settings.liveReload` boolean option to the project configuration schema, available with specVersion 5.0 and higher. - BuildServer now emits a debounced `sourcesChanged` event (100ms debounce) whenever watched source files change, so a burst of changes results in a single notification. JIRA: CPOUI5FOUNDATION-1224
- Add new `--live-reload` CLI flag (defaults to true) for the `ui5 serve` command. Pass `--no-live-reload` to disable it. - The flag overrides the `server.settings.liveReload` setting in the project's `ui5.yaml`. - When neither the CLI flag nor the configuration sets a value, live reload is enabled by default. JIRA: CPOUI5FOUNDATION-1224
|
|
||
| When live reload is active, the UI5 server opens a WebSocket connection that notifies the browser of source changes and triggers a page reload. | ||
|
|
||
| Reloads are driven by the `BuildServer`, which emits a debounced `sourcesChanged` event whenever watched source files change. A burst of changes therefore results in a single reload notification. |
There was a problem hiding this comment.
I really like the detailed documentation but I would recommend to have a more abstract / consumer friendly first section and then describing the technical details in a second section. The consumer has to know whats the benefit of this middleware and how to control it. IMHO The underlying technical aspects are only relevant for experts or custom middleware developers.
|
|
||
| When live reload is active, the UI5 server opens a WebSocket connection that notifies the browser of source changes and triggers a page reload. | ||
|
|
||
| Reloads are driven by the `BuildServer`, which emits a debounced `sourcesChanged` event whenever watched source files change. A burst of changes therefore results in a single reload notification. |
JIRA: CPOUI5FOUNDATION-1224