Skip to content

Commit a4ee334

Browse files
authored
Use local javascript assets (#4)
1 parent 40486c0 commit a4ee334

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

lib/phoenix_playground/endpoint.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ defmodule PhoenixPlayground.Endpoint do
7474
socket "/live", Phoenix.LiveView.Socket
7575
socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
7676

77+
plug Plug.Static, from: {:phoenix, "priv/static"}, at: "/assets/phoenix"
78+
plug Plug.Static, from: {:phoenix_live_view, "priv/static"}, at: "/assets/phoenix_live_view"
79+
7780
plug Phoenix.LiveReloader
7881

7982
plug Plug.Parsers,

lib/phoenix_playground/layouts.ex

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@ defmodule PhoenixPlayground.Layouts do
2020

2121
def render("live.html", assigns) do
2222
~H"""
23-
<script src={"https://cdn.jsdelivr.net/npm/phoenix@#{phx_vsn()}/priv/static/phoenix.min.js"}>
24-
</script>
25-
<script
26-
src={"https://cdn.jsdelivr.net/npm/phoenix_live_view@#{lv_vsn()}/priv/static/phoenix_live_view.min.js"}
27-
>
28-
</script>
23+
<script src="/assets/phoenix/phoenix.js"></script>
24+
<script src="/assets/phoenix_live_view/phoenix_live_view.js"></script>
2925
<script>
3026
let liveSocket = new window.LiveView.LiveSocket("/live", window.Phoenix.Socket)
3127
liveSocket.connect()
@@ -59,7 +55,4 @@ defmodule PhoenixPlayground.Layouts do
5955
<%= @inner_content %>
6056
"""
6157
end
62-
63-
defp phx_vsn, do: Application.spec(:phoenix, :vsn)
64-
defp lv_vsn, do: Application.spec(:phoenix_live_view, :vsn)
6558
end

0 commit comments

Comments
 (0)