JBoss.orgCommunity Documentation

Chapter 4. LiveReload Tools

4.1. Overview of LiveReload Tools
4.1.1. About LiveReload
4.1.2. About LiveReload Tools
4.2. Features of LiveReload Tools
4.2.1. Features Overview
4.2.2. Create a LiveReload Server
4.2.3. Configure the LiveReload Server
4.2.4. View Resources in LiveReload-enabled Browsers
4.2.5. View Resources in LiveReload-enabled BrowserSim

The LiveReload server is integral to the LiveReload integration with the IDE. In its default configuration, the server receives information from the IDE when resources change and sends notifications for refresh actions to be taken. The server may also be further configured to inject the necessary JavaScript code snippets into HTML files or enable remote connections. The procedure below guides you through creating a default LiveReload server.

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 view 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 view right-click the LiveReload server and click Restart.

You can use the actions of LiveReload Tools to open HTML, XHTML and AsciiDoc resources in LiveReload-enabled browsers, as detailed below. 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. Note that LiveReload Tools functionality may only work with deployed XHTML resources due to their dynamic nature.

Note

To use LiveReload Tools with AsciiDoc files, you must install the AsciiDoctor.js browser extension from http://asciidoctor.org/news/2013/09/18/introducing-asciidoctor-js-live-preview/ on the Asciidoctor website. The browser extension renders AsciiDoc files as HTML and it is available for Chrome and FireFox.

View workspace resources in a web browser

In the Project Explorer view, right-click the resource 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 web browser

Ensure the server and application of the deployed resources are started. In the Servers view, 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 Preferences window.

View deployed resources on an external device

Ensure the server and application of the deployed resources are started. In the Servers view, 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.