Skip to content

Live reload support (--live-reload flag) #110

Description

@melvincarvalho

Summary

Add --live-reload flag that auto-refreshes the browser when files change, leveraging existing WebSocket notifications.

Implementation

Minimal addition (~20 lines):

  1. Add --live-reload flag to CLI
  2. When enabled, auto-enable notifications WebSocket
  3. Inject small client script into HTML responses:
<script>(function(){
  var ws = new WebSocket((location.protocol==='https:'?'wss:':'ws:') + '//' + location.host + '/notifications/');
  ws.onmessage = function() { location.reload() };
  ws.onclose = function() { setTimeout(function(){ location.reload() }, 1000) };
})();</script>

Usage

jss start --live-reload

Browser auto-refreshes when any file is created/updated/deleted via PUT/DELETE.

Use Case

Primary consumer is servejss (npx serve alternative) which will pass this flag for local development.

Complexity

  • ~15 lines for script injection helper
  • ~5 lines for flag/config wiring
  • Leverages existing notifications infrastructure

Related: JavaScriptSolidServer/jsserve#1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions