phoenixframework/phoenix_live_reload

Name: phoenix_live_reload

Owner: phoenixframework

Description: Provides live-reload functionality for Phoenix

Created: 2015-03-24 03:57:55.0

Updated: 2018-05-12 17:49:40.0

Pushed: 2018-05-18 17:22:16.0

Homepage:

Size: 78

Language: Elixir

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

A project for live-reload functionality for Phoenix during development.

Usage

You can use phoenix_live_reload in your projects by adding it to your mix.exs dependencies:

deps do
:phoenix_live_reload, "~> 1.1"}]

You can configure the reloading interval in ms in your config/dev.exs:

tch static and templates for browser reloading.
ig :my_app, MyAppWeb.Endpoint,
ve_reload: [
interval: 1000,
patterns: [
  ...

The default interval is 100ms.

Backends

This project uses FileSystem as a dependency to watch your filesystem whenever there is a change and it supports the following operating systems:

Skipping remote CSS reload

All stylesheets are reloaded without a page refresh anytime a style is detected as having changed. In certain cases such as serving stylesheets from a remote host, you may wish to prevent unnecessary reload of these stylesheets during development. For this, you can include a data-no-reload attribute on the link tag, ie:

<link rel="stylesheet" href="http://example.com/style.css" data-no-reload>
Differences between Phoenix.CodeReloader

Phoenix.CodeReloader recompiles code in the lib directory. This means that if you change anything in the lib directory (such as a context) then the Elixir code will be reloaded and used on your next request.

In contrast, this project adds a plug which injects some JavaScript into your page with a WebSocket connection to the server. When you make a change to anything in your config for live_reload (JavaScript, stylesheets, templates and views by default) then the page will be reloaded in response to a message sent via the WebSocket. If the change was to an Elixir file then it will be recompiled and served when the page is reloaded. If it is JavaScript or CSS, then only assets are reloaded, without triggering a full page load.

License

Same license as Phoenix.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.