Phoenix Live-Reload v1.2.3 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
All live-reloading configuration must be done inside the :live_reload
key of your endpoint, such as this:
config :my_app, MyApp.Endpoint,
...
live_reload: [
patterns: [
~r{priv/static/.*(js|css|png|jpeg|jpg|gif)$},
~r{lib/my_app_web/views/.*(ex)$},
~r{lib/my_app_web/templates/.*(eex)$}
]
]
The following options are supported:
:patterns
- a list of patterns to trigger the live reloading. This option is required to enable any live reloading.:iframe_class
- a class to be used to be given to the iframe injected by live reload. By default the iframe uses a "style" attribute to hide itself but that can conflict with Content Security Policies. By giving a class, you disable the default style and control the styling of the iframe.:url
- the URL of the live reload socket connection. By default it will use the browser's host and port.:suffix
- if you are running live-reloading on an umbrella app, you may want to give a different suffix to each socket connection. You can do so with the:suffix
option:live_reload: [ suffix: "/proxied/app/path" ]
And then configure the endpoint to use the same suffix:
if code_reloading? do socket "/phoenix/live_reload/socket/proxied/app/path", Phoenix.LiveReloader.Socket ... end
Link to this section Summary
Link to this section Functions
Callback implementation for Plug.call/2
.
Callback implementation for Plug.init/1
.