Skip to content

Commit 11dde5e

Browse files
authored
Read assets during compilation (#32)
Read CSS and JS assets during compilation. This ensures that the CSS and JS files are present when the release is built and then they are not needed anymore as they have been compiled.
1 parent 46bb575 commit 11dde5e

File tree

4 files changed

+1430
-8
lines changed

4 files changed

+1430
-8
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,5 @@ error_tracker-*.tar
2727

2828
/assets/node_modules
2929

30-
/priv/static/app.js
31-
/priv/static/app.css
3230

3331
dev.local.exs

lib/error_tracker/web/components/layouts.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ defmodule ErrorTracker.Web.Layouts do
44

55
alias ErrorTracker.Web.Layouts.Navbar
66

7-
@css_path :code.priv_dir(:error_tracker) |> Path.join("static/app.css")
8-
@js_path :code.priv_dir(:error_tracker) |> Path.join("static/app.js")
7+
@default_socket_config %{path: "/live", transport: :websocket}
98

10-
@default_docket_config %{path: "/live", transport: :websocket}
9+
@css :code.priv_dir(:error_tracker) |> Path.join("static/app.css") |> File.read!()
10+
@js :code.priv_dir(:error_tracker) |> Path.join("static/app.js") |> File.read!()
1111

1212
embed_templates "layouts/*"
1313

14-
def get_content(:css), do: File.read!(@css_path)
15-
def get_content(:js), do: File.read!(@js_path)
14+
def get_content(:css), do: @css
15+
def get_content(:js), do: @js
1616

1717
def get_socket_config(key) do
18-
default = Map.get(@default_docket_config, key)
18+
default = Map.get(@default_socket_config, key)
1919
config = Application.get_env(:error_tracker, :live_view_socket, [])
2020
Keyword.get(config, key, default)
2121
end

0 commit comments

Comments
 (0)