Context:
I have developed a game server backend in a single phoenix project. It has grown in complexity and size over last 3 years. I want to split the project into multiple projects like model, admin web , api web, realtime web, customisations runtime, etc.
I am trying to split my project into smaller projects similar to phoenix_live_dashboard.
While doing so I had this error - module Routes is not available or is yet to be defined
--- web.ex ---
defp view_helpers do
quote do
# Use all HTML functionality (forms, tags, etc)
use Phoenix.HTML
# Import basic rendering functionality (render, render_layout, etc)
import Phoenix.View
import IndyAdminWeb.ErrorHelpers
import AdminWeb.Gettext
# original - alias AdminWeb.Router.Helpers, as: Routes
# This works - alias unquote(Application.get_env(:admin, :router)), as: Routes
# Below code does not work -
if Mix.env() in [:dev, :test] do
alias AdminWeb.Router.Helpers, as: Routes
end
end
end
Mix.env() based alias gives an error,
Routes.static_path/2 is undefined (module Routes is not available or is yet to be defined)
So I tried below the router from config and it works.
alias unquote(Application.get_env(:admin, :router)), as: Routes
What am I missing in case of if Mix.env() scenario. Why does it fail with Routes is not available.
Edited: couple of sentences for clarity.