From a94e0a24df7b41cdf2196e4021d7286fd1610546 Mon Sep 17 00:00:00 2001 From: nelsonic Date: Fri, 21 Oct 2022 20:55:33 +0100 Subject: [PATCH] live-reloading working with Tailwind in LiveView #220 --- config/config.exs | 2 +- config/dev.exs | 7 ++-- lib/auth_web/live/groups_live.html.heex | 5 ++- lib/auth_web/templates/layout/live.html.heex | 35 +++++++++----------- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/config/config.exs b/config/config.exs index d1115a1d..eee5b2fe 100644 --- a/config/config.exs +++ b/config/config.exs @@ -36,7 +36,7 @@ import_config "#{Mix.env()}.exs" # https://gist.github.com/chrismccord/2ab350f154235ad4a4d0f4de6decba7b # Configure esbuild (the version is required) config :esbuild, - version: "0.12.18", + version: "0.14.29", default: [ args: ~w(js/app.js --bundle --target=es2016 --outdir=../priv/static/assets), cd: Path.expand("../assets", __DIR__), diff --git a/config/dev.exs b/config/dev.exs index 7f616d82..aa73e863 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -20,9 +20,11 @@ config :auth, AuthWeb.Endpoint, debug_errors: true, code_reloader: true, check_origin: false, + secret_key_base: "aMh0TI5FqAjFd9Xa+kRAlNfq1OzVb6NmiciLcpgiuU9mpCYjc78L+5cPte+Bqo0m", watchers: [ # Start the esbuild watcher by calling Esbuild.install_and_run(:default, args) - esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]} + esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]}, + tailwind: {Tailwind, :install_and_run, [:default, ~w(--watch)]} ] # ## SSL Support @@ -56,7 +58,8 @@ config :auth, AuthWeb.Endpoint, ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", ~r"priv/gettext/.*(po)$", ~r"lib/auth_web/(live|views)/.*(ex)$", - ~r"lib/auth_web/templates/.*(eex)$" + ~r"lib/auth_web/templates/.*(eex)$", + ~r"lib/auth_web/live/.*(heex)$" ] ] diff --git a/lib/auth_web/live/groups_live.html.heex b/lib/auth_web/live/groups_live.html.heex index 33ae494a..f5fe75d0 100644 --- a/lib/auth_web/live/groups_live.html.heex +++ b/lib/auth_web/live/groups_live.html.heex @@ -1 +1,4 @@ -

Groups LiveView!

\ No newline at end of file +

+ Groups LiveView! +

\ No newline at end of file diff --git a/lib/auth_web/templates/layout/live.html.heex b/lib/auth_web/templates/layout/live.html.heex index 35bd05e3..9c077b3d 100644 --- a/lib/auth_web/templates/layout/live.html.heex +++ b/lib/auth_web/templates/layout/live.html.heex @@ -1,20 +1,17 @@ - -<.container class="my-10"> - <.alert - color="info" - class="mb-5" - label={live_flash(@flash, :info)} - phx-click="lv:clear-flash" - phx-value-key="info" - /> + + + + + + + <%= assigns[:page_title] || "Auth App" %> + <%= csrf_meta_tag() %> + + + - <.alert - color="danger" - class="mb-5" - label={live_flash(@flash, :error)} - phx-click="lv:clear-flash" - phx-value-key="error" - /> - - <%= @inner_content %> - \ No newline at end of file + + <%= @inner_content %> + + +