add include_assets

This commit is contained in:
Mayel 2021-06-03 18:46:51 +02:00
parent 7e74b70131
commit 761b026008
6 changed files with 18 additions and 3 deletions

1
.gitignore vendored
View file

@ -65,3 +65,4 @@ deps.path*
.bash_history
schema.graphql
deploy
.pnpm-debug.log

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View file

@ -2,7 +2,7 @@
# make sure you change everything to your own secrets!
# and do not check this into git or any public host
# for sessions/cookies
# for sessions/cookies, you can generate strings for these by running: mix phx.gen.secret
SECRET_KEY_BASE="you-should-put-a-secure-string-here"
SIGNING_SALT="you-should-put-a-different-secure-string-here"
ENCRYPTION_SALT="you-should-put-yet-another-secure-string-here"

View file

@ -2,7 +2,7 @@
# make sure you change everything to your own secrets!
# and do not check this into git or any public host
# for sessions/cookies
# for sessions/cookies, you can generate strings for these by running: mix phx.gen.secret
SECRET_KEY_BASE="you-should-put-a-secure-string-here"
SIGNING_SALT="you-should-put-a-different-secure-string-here"
ENCRYPTION_SALT="you-should-put-yet-another-secure-string-here"

View file

@ -27,7 +27,7 @@ defmodule Bonfire.Web.Endpoint do
at: "/",
from: :bonfire,
gzip: true,
only: ~w(data css fonts images js favicon.ico robots.txt)
only: ~w(data css fonts images js favicon.ico robots.txt cache_manifest.json)
# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
@ -54,4 +54,18 @@ defmodule Bonfire.Web.Endpoint do
plug Plug.Head
plug Plug.Session, @session_options
plug Bonfire.Web.Router
def include_assets(conn) do
js = if Bonfire.Common.Utils.e(conn, :assigns, :current_account, nil) do
static_path("/js/live.js")
else
static_path("/js/non_live.js")
end
if Bonfire.Common.Config.get!(:env) == :dev do
"<link phx-track-static rel='stylesheet' href='"<> static_path("/css/app.css") <>"'/> <script defer phx-track-static src='"<> js <>"'></script>"
else
"<link phx-track-static rel='stylesheet' href='"<> static_path("/css/app.css") <>"'/> <script defer phx-track-static src='"<> js <>"'></script> "
end
end
end