Switch from exsync to Phoenix.CodeReloader + live_code_reloader

This commit is contained in:
Mayel de Borniol 2022-10-06 16:47:10 +13:00
parent 014510977e
commit b130d93ac9
7 changed files with 31 additions and 27 deletions

View file

@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
## [Unreleased (2022-10-02)]
## [Unreleased (2022-10-06)]
### Added
- Enable/disable extensions [#448](https://github.com/bonfire-networks/bonfire-app/issues/448)
- Coordination MVP [#445](https://github.com/bonfire-networks/bonfire-app/issues/445) by mayel & ivanminutillo

View file

@ -12,19 +12,28 @@ config :bonfire, Bonfire.Common.Repo,
# EctoSparkles does the logging instead
log: false
path_dep_dirs =
Mess.deps([path: "deps.path"], [])
|> Enum.map(&(Keyword.fetch!(elem(&1, 1), :path) <> "/lib"))
local_deps = Mess.deps([path: Path.relative_to_cwd("config/deps.path")], [])
local_dep_names = Enum.map(local_deps, &elem(&1, 0))
dep_paths = Enum.map(local_deps, &(Keyword.fetch!(elem(&1, 1), :path) <> "/lib"))
watch_paths = dep_paths ++ ["lib/"] ++ ["priv/static/"]
IO.puts("Watching these deps for code reloading: #{inspect(local_dep_names)}")
config :phoenix_live_reload,
# watch the app's lib/ dir + the dep/lib/ dir of every locally-cloned dep
dirs: path_dep_dirs ++ ["lib/"]
dirs: watch_paths
# to include cloned code in patterns
path_dep_patterns = Enum.map(path_dep_dirs, &(String.slice(&1, 2..1000) <> ".*ex"))
# Surface views
path_dep_patterns =
(path_dep_patterns ++ path_dep_dirs) |> Enum.map(&(String.slice(&1, 2..1000) <> ".*sface"))
# filename patterns that should trigger page reloads (only within the above dirs)
patterns = [
~r"^priv/static/.*(js|css|png|jpeg|jpg|gif|svg|webp)$",
# ~r"^priv/gettext/.*(po)$",
~r"_live\.ex$",
~r{(views|templates|pages|components)/.*(ex)$},
~r".*(heex|leex|sface)$",
~r"priv/catalogue/.*(ex)$"
]
IO.puts("Watching these filenames for live reloading in the browser: #{inspect(patterns)}")
# Watch static and templates for browser reloading.
config :bonfire, Bonfire.Web.Endpoint,
@ -32,6 +41,7 @@ config :bonfire, Bonfire.Web.Endpoint,
debug_errors: true,
check_origin: false,
code_reloader: true,
reloadable_apps: [:bonfire] ++ local_dep_names,
watchers: [
yarn: [
"watch.js",
@ -47,19 +57,7 @@ config :bonfire, Bonfire.Web.Endpoint,
]
],
live_reload: [
patterns:
[
# ~r"^priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
# ~r"^priv/gettext/.*(po)$",
# ~r"^web/(live|views)/.*ex$",
# ~r"^lib/.*_live\.ex$",
# ~r".*leex$",
# defp elixirc_paths(:dev), do: ["lib"] ++ catalogues()
~r"lib/.*ex$",
~r".*sface$",
~r"priv/catalogue/.*(ex)$"
] ++ path_dep_patterns
patterns: patterns
]
config :bonfire, Bonfire.Web.Endpoint, phoenix_profiler: [server: Bonfire.Web.Profiler]

View file

@ -540,6 +540,10 @@ docker-stop-web:
#### MISC COMMANDS ####
# Open an interactive console
@imix *args='':
just cmd iex -S mix $@
# Run a specific mix command, eg: `just mix deps.get` or `just mix "deps.update pointers"`
@mix *args='':
just cmd mix $@

View file

@ -67,4 +67,6 @@ defmodule Bonfire.Web.Endpoint do
<script defer phx-track-static crossorigin='anonymous' src='#{js}'></script>
"""
end
def reload!(), do: Phoenix.CodeReloader.reload!(__MODULE__)
end

View file

@ -46,7 +46,7 @@ defmodule Bonfire.Web.HomeLive do
# {Bonfire.UI.Common.WidgetInstanceInfoLive, [display_banner: false]},
# {Bonfire.UI.Common.WidgetLinksLive, [links: links]},
# {Bonfire.UI.Me.WidgetAdminsLive, []},
# {Bonfire.UI.Social.WidgetTagsLive, [links: links]}
# {Bonfire.Tag.Web.WidgetTagsLive, [links: links]}
# ]
# ],
# guests: [
@ -55,7 +55,7 @@ defmodule Bonfire.Web.HomeLive do
# # {Bonfire.UI.Common.WidgetInstanceInfoLive, [display_banner: false]},
# # {Bonfire.UI.Common.WidgetLinksLive, [links: links]},
# # {Bonfire.UI.Me.WidgetAdminsLive, []},
# # {Bonfire.UI.Social.WidgetTagsLive, [links: links]}
# # {Bonfire.Tag.Web.WidgetTagsLive, [links: links]}
# ]
# ],
]

View file

@ -51,6 +51,6 @@
<Bonfire.UI.Me.LoginViewLive :if={is_nil(@current_user)} form={@form} error={@error} />
<Bonfire.UI.Me.WidgetAdminsLive />
<Bonfire.UI.Common.WidgetAppsLive />
<Bonfire.UI.Social.WidgetTagsLive :if={not is_nil(@current_user)} />
<Bonfire.Tag.Web.WidgetTagsLive :if={not is_nil(@current_user)} />
</div>
</div>

View file

@ -244,7 +244,7 @@ defmodule Bonfire.MixProject do
## dev conveniences
# {:dbg, "~> 1.0", only: [:dev, :test]},
{:phoenix_live_reload, "~> 1.3", only: :dev},
{:exsync, git: "https://github.com/falood/exsync", only: :dev},
# {:exsync, git: "https://github.com/falood/exsync", only: :dev},
# {:mix_unused, "~> 0.4", only: :dev},
{:ex_doc, "~> 0.28.3", only: [:dev, :test], runtime: false},
{:ecto_erd, "~> 0.4", only: :dev},