Phoenix Live-Reload v1.2.2 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)$}
]
]
In case you have an umbrella app that runs different instances of live reload on proxied paths
you can suffix the path to make them match properly. You can pass the :suffix
option, ie:
config :my_app, MyApp.Endpoint,
...
live_reload: [
suffix: "/proxied/app/path",
patterns: [
~r{priv/static/.*(js|css|png|jpeg|jpg|gif)$},
~r{web/views/.*(ex)$},
~r{web/templates/.*(eex)$}
]
]
You will also need to modify the socket path in lib/myapp_web/endpoint.ex
:
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
.