Add mechanism to allow developers to Hot Reload certain Package assets #9027
Labels
packages
Issues related to add-on packages, systems, modules, and worlds
Milestone
Summary
Hot reloading is a feature where changes to certain files are captured and inserted into a live page in realtime without reloading. This can help speed up development tasks such as styling, templating, and localization.
Core Behavior
The following core behaviors are available out of the box. Only actively enabled packages will receive hot reload events.
HTML and HBS
Template files update the registered Handlebars partials and
_templateCache
, and then any open applications are rerenderedNote: Rerendering open apps redraws the entire app, and does not attempt to save any edits in progress
JSON
If the modified file is the current active language for the package (as defined in
languages
) such asen.json
,game.i18n.translations
is updated with the new localization entries and then any open applications are renderedNote: Rerendering open apps redraws the entire app, and does not attempt to save any edits in progress
CSS
Style files reload the stylesheet, usually resulting in a brief flash as the page redraws with the new styles
How to setup Hot Reloading
An active package can opt-in to hot reload by declaring
flags.hotReload
in their manifest, with the following structure:Example:
Performance note: There is an overhead to watching too many files for changes - serializing those and sending them to the client is somewhat costly, and if you watch too broadly such that dozens of files change at once (such as some build operations), you will experience lag. It is generally better to define
paths
narrowly.As of #9083, you'll also need to enable hot reloading for the server in your options.json, editable in the Setup screen options:
How to extend Core Behavior
Before Core hot reload behavior executes, the
hotReload
hook is fired with the following data object:Registering a hook for this event that returns
false
will prevent core behavior from occurring.The text was updated successfully, but these errors were encountered: