diff --git a/lib/phoenix_live_reload/channel.ex b/lib/phoenix_live_reload/channel.ex index c89807f..5d665c4 100644 --- a/lib/phoenix_live_reload/channel.ex +++ b/lib/phoenix_live_reload/channel.ex @@ -19,9 +19,6 @@ defmodule Phoenix.LiveReloader.Channel do WebConsoleLogger.subscribe(@logs) end - deps_paths = - for {app, path} <- Mix.Project.deps_paths(), into: %{}, do: {to_string(app), path} - config = socket.endpoint.config(:live_reload) socket = @@ -29,7 +26,7 @@ defmodule Phoenix.LiveReloader.Channel do |> assign(:patterns, config[:patterns] || []) |> assign(:debounce, config[:debounce] || 0) |> assign(:notify_patterns, config[:notify] || []) - |> assign(:deps_paths, deps_paths) + |> assign(:deps_paths, deps_paths()) {:ok, join_info(), socket} else @@ -133,4 +130,12 @@ defmodule Phoenix.LiveReloader.Channel do %{} end end + + defp deps_paths do + if Code.loaded?(Mix.Project) do + for {app, path} <- Mix.Project.deps_paths(), into: %{}, do: {to_string(app), path} + else + %{} + end + end end