Exadra37
Phoenix Live Reload default setup leaves out some code files, Why?
DISCLAIMER: I just play with Elixir and Phoenix occasionally.
In a default install of Phoenix we get this config:
config :tasks, TasksWeb.Endpoint,
live_reload: [
patterns: [
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/tasks_web/{live,views}/.*(ex)$",
~r"lib/tasks_web/templates/.*(eex)$"
]
]
The problem with the above config is that each time I edit a code file outside templates, views or live I need to manually restart the server, and this is so annoying and prone to forget, thus leading to debugging an error that doesn’t exist, aka I just forgot to restart the server… or am I missing something?
But this config works like a charm to me:
config :tasks, TasksWeb.Endpoint,
live_reload: [
patterns: [
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/tasks_web/.*(ex)$",
~r"lib/tasks/.*(ex)$",
]
]
So can I run in any weird situation because of using this type of live reload config?
Would not be better to have this live reload config by default?
First Post!
benwilson512
The live reload config you see here is about which files should, immediately on save, automatically trigger the page itself to reload.
It’s the code_reloader that handles recompiling your core Elixir code on page refresh. I ran a new copy of phoenix and saw the following in endpoint.ex:
# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
if code_reloading? do
socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
plug Phoenix.LiveReloader
plug Phoenix.CodeReloader
end
And when I checked dev.exs I see:
config :my_app_web, MyAppWeb.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [
node: [
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch-stdin",
cd: Path.expand("../apps/my_app_web/assets", __DIR__)
]
]
Importantly code_reloader: true. Does this line up with what you see in your project?
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








