JBoss.orgCommunity Documentation

Chapter 5. LiveReload Tools

5.1. Overview of LiveReload Tools
5.1.1. About LiveReload
5.1.2. About LiveReload Tools
5.2. Features of LiveReload Tools
5.2.1. Features Overview
5.2.2. Create a LiveReload Server
5.2.3. Configure the LiveReload Server
5.2.4. View Resources in LiveReload-enabled Browsers
5.2.5. View Resources in LiveReload-enabled BrowserSim

A LiveReload client must be inserted into HTML files in order for it to receive the LiveReload server notifications about changed resources. LiveReload Tools provides additional configuration options so that the LiveReload server can inject the necessary <script> element into the HTML resources. Furthermore, the LiveReload server can be configured to allow access from external devices, enabling LiveReload to function in browsers of remote devices.

The details below outline how to set the configuration options using the Server Editor. To open the Server Editor for a LiveReload server, in the Servers tab double-click the LiveReload server. Alternatively, right-click the LiveReload server and click Open or press F3.


Insert JavaScript code snippet to resources

In the Server Editor under LiveReload Server Configuration, select the Inject the livereload.js script in HTML pages check box.

Enable LiveReload in external device browsers

In the Server Editor under LiveReload Server Configuration, select the Allow Remote Connections check box. This option is disabled by default when a LiveReload server is created as it exposes your workspace files, which may not always be desirable.

All changes to the settings of a LiveReload server must be saved and the server restarted before the results will take effect. To save setting changes, press Ctrl+S or click FileSave or click the Save icon. To restart the server, in the Servers tab right-click the LiveReload server and click Restart.

You can use the actions of LiveReload Tools to open resources in browsers with LiveReload enabled, as detailed below. Note that if the requisite LiveReload server does not exist or is not correctly configured, you are prompted by LiveReload Tools, which can complete the necessary requirements for you.

View workspace resources on an external device

In the Project Explorer tab, right-click the HTML file and click Open WithWeb Browser via LiveReload Server.


This requires the server to be configured to Inject the livereload.js script in HTML pages and, if the server is not correctly configured, you are prompted to enable this option.


The IDE-specified external web browser opens, with LiveReload activated, and displays the workspace resource.

View deployed resources in a system browser

Ensure the server and application of the deployed resources are started. In the Servers tab, right-click the application and click Show InWeb Browser via LiveReload Server.


This requires the server to be configured to Inject the livereload.js script in HTML pages and, if the server is not correctly configured, you are prompted to enable this option.


The IDE-specified external web browser opens, with LiveReload activated, and displays the deployed resource.

Note

To change the IDE-specified external web browser, click WindowPreferences and expand GeneralWeb Browser. From the External web browsers list, select the browser to use for actions involving external web browsers. Click Apply and click OK to close the window.

View deployed resources on an external device

Ensure the server and application of the deployed resources are started. In the Servers tab, right-click the application and click Show InWeb Browser on External Device.


This requires the server to be configured to Inject the livereload.js script in HTML pages and Allow Remote Connections and, if the server is not correctly configured, you are prompted to enable these options.


A QR code and LiveReload server port URL corresponding to the deployed application are displayed and these can be input into external device browsers.


The LiveReload server can be used in conjunction with BrowserSim. In this case, the server sends notifications about changed resources and BrowserSim inserts the JavaScript code, which invokes the simulated device browser window to refresh. The procedure below outlines how to enable LiveReload in BrowserSim for workspace and deployed resources.