Phoenix.LiveReloader
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)$} ] ]
Summary↑
call(conn, opts) | Callback invoked by Plug on every request |
init(opts) | Callback required by Plug that initializes the router for serving web requests |
Functions
Callback invoked by Plug on every request.
Callback required by Plug that initializes the router for serving web requests.