Skip to content

Commit 2e97a04

Browse files
committed
fix: add static asset routes for arizona and fix asset paths
1 parent 2d79f6b commit 2e97a04

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/rebar3_nova_new.erl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,11 @@ generate_router(Name, #{arizona := true}) ->
621621
" {\"/\", fun ",
622622
Name,
623623
"_main_controller:index/1, #{methods => [get]}},\n",
624-
" {\"/heartbeat\", fun(_) -> {status, 200} end, #{methods => [get]}}\n",
624+
" {\"/heartbeat\", fun(_) -> {status, 200} end, #{methods => [get]}},\n",
625+
" %% App static assets (priv/static/assets/)\n",
626+
" {\"/assets/[...]\", \"static/assets\"},\n",
627+
" %% Arizona JS from arizona_core priv\n",
628+
" {\"/arizona/[...]\", {priv_dir, arizona_core, \"static/assets\"}}\n",
625629
" ]\n",
626630
" }\n",
627631
" ].\n"
@@ -684,15 +688,15 @@ generate_controller(Name, #{arizona := true}) ->
684688
" \"<title>",
685689
Name,
686690
"</title>\"\n",
687-
" \"<link rel=\\\"stylesheet\\\" href=\\\"/assets/css/app.css\\\">\"\n",
691+
" \"<link rel=\\\"stylesheet\\\" href=\\\"/assets/app.css\\\">\"\n",
688692
" \"</head>\"\n",
689693
" \"<body>\"\n",
690694
" \"<div id=\\\"app\\\"><h1>Welcome to ",
691695
Name,
692696
"</h1>\"\n",
693697
" \"<p>Powered by Nova + Arizona</p></div>\"\n",
694698
" \"<script type=\\\"module\\\">\"\n",
695-
" \"import Arizona from '/assets/js/arizona.min.js';\"\n",
699+
" \"import Arizona from '/arizona/js/arizona.min.js';\"\n",
696700
" \"globalThis.arizona = new Arizona();\"\n",
697701
" \"arizona.connect('/live');\"\n",
698702
" \"</script>\"\n",
@@ -1188,7 +1192,7 @@ generate_home_view(Name) ->
11881192
rebar3_nova_utils:write_file(Path, Content).
11891193

11901194
generate_app_css(Name) ->
1191-
Path = filename:join([Name, "priv", "assets", "app.css"]),
1195+
Path = filename:join([Name, "priv", "static", "assets", "app.css"]),
11921196
Content = [
11931197
"* {\n",
11941198
" margin: 0;\n",

test/rebar3_nova_new_SUITE.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ arizona_flag(_Config) ->
138138
rebar3_nova_new:generate_project(Name, Flags),
139139

140140
assert_file_exists(Name, "src/views/testapp_arizona_home_view.erl"),
141-
assert_file_exists(Name, "priv/assets/app.css"),
141+
assert_file_exists(Name, "priv/static/assets/app.css"),
142142
assert_file_not_exists(Name, "src/views/testapp_arizona_main.dtl"),
143143

144144
HomeView = read_file(Name, "src/views/testapp_arizona_home_view.erl"),
@@ -241,7 +241,7 @@ combined_kura_arizona_ci(_Config) ->
241241
assert_file_exists(Name, "src/testapp_combo_repo.erl"),
242242
assert_file_exists(Name, "docker-compose.yml"),
243243
assert_file_exists(Name, "src/views/testapp_combo_home_view.erl"),
244-
assert_file_exists(Name, "priv/assets/app.css"),
244+
assert_file_exists(Name, "priv/static/assets/app.css"),
245245
assert_file_exists(Name, ".github/workflows/ci.yml"),
246246
assert_file_not_exists(Name, "src/views/testapp_combo_main.dtl"),
247247

0 commit comments

Comments
 (0)