Phoenix Live-Reload v1.2.1 Phoenix.LiveReloader View Source

Router for live-reload detection in development.

Usage

Add the Phoenix.LiveReloader plug within a code_reloading? block in your Endpoint, ie:

if code_reloading? do
  socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
  plug Phoenix.CodeReloader
  plug Phoenix.LiveReloader
end

Configuration

For live-reloading in development, add the following :live_reload configuration to your Endpoint with a list of patterns to watch for changes:

config :my_app, MyApp.Endpoint,
...
live_reload: [
  patterns: [
    ~r{priv/static/.*(js|css|png|jpeg|jpg|gif)$},
    ~r{web/views/.*(ex)$},
    ~r{web/templates/.*(eex)$}
  ]
]

By default the URL of the live-reload connection will use the browser’s host and port. To override this, you can pass the :url option, ie:

config :my_app, MyApp.Endpoint,
...
live_reload: [
  url: "ws://localhost:4000",
  patterns: [
    ~r{priv/static/.*(js|css|png|jpeg|jpg|gif)$},
    ~r{web/views/.*(ex)$},
    ~r{web/templates/.*(eex)$}
  ]
]

Link to this section Summary

Functions

Callback implementation for Plug.call/2

Callback implementation for Plug.init/1

Link to this section Functions

Callback implementation for Plug.call/2.

Callback implementation for Plug.init/1.