Gigitsu
Phoenix code reload in umbrella with multiple app
I have an umbrella project with multiple apps. Two are just libraries with utilities and shared code, while the others are Phoenix applications that can be served.
For instance:
Umbrella app
├── core (shared library)
├── common (shared library)
│
├── backoffice (phoenix app)
│ depends on
│ ├── common (in umbrella)
│ └── core (in umbrella)
├── frontend_1 (phoenix app)
│ depends on
│ ├── common (in umbrella)
│ └── core (in umbrella)
├── frontend_2 (phoenix app)
│ depends on
│ ├── common (in umbrella)
│ └── core (in umbrella)
During my development process, I need to start one Phoenix app at a time, and I do this with:
mix do --app backoffice cmd mix phx.server
But in this way, if I change something in core or common, the code is not hot reloaded and I need to restart the server for the changes to take effect.
How can I fix this? Can I start the server from the umbrella root but selecting only one app?
Most Liked
hubertlepicki
Hang on @Gigitsu I have you covered with my own contribution to Phoenix xD.
Check out the :reloadable_apps option that I added to Phoenix a while ago. My use case was similar but not identical, so I am wondering if it will work for you.
config :your_app, Backoffice.Endpoint,
reloadable_apps: [:frontend_1, :frontend_2, :backoffice, :core, :common]
Gigitsu
Thanks @samaravilha.
I’ve managed to get code reload working by adding the following configurations in my dev.exs file
config :phoenix_live_reload, :dirs, [
Path.expand("../apps/my_app", __DIR__),
Path.expand("../apps/common", __DIR__),
Path.expand("../apps/core", __DIR__)
]
config :my_app, MyApp.Endpoint,
live_reload: [
patterns: [
~r"../common/lib/common/(\w+/)*.*(ex|heex)$",
~r"../core/lib/core/(\w+/)*.*(ex|heex)$",
~r"priv/gettext/.*(po)$",
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"lib/my_app/(controllers|live|components)/.*(ex|heex)$"
]
]
config :my_app, MyApp.Endpoint,
...
reloadable_apps: [:my_app , :core, :common],
...
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
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









