Novice User for Phoenix, Tailwinds and Elixir.
ISSUE: Can’t get priv/static/assets/app.css to regenerate after I make changes to assets/css/app.css or when I remove priv/static/assets/app.css altogether.
I have just upgraded to Phoenix 1.6.6. I managed to get my app working again after making all of the necessary changes, but the css formatting was gone. So I followed the Pragmatic Studio instructions on how to upgrade Tailwinds to work with 1.6.6. Formatting is still wonky.
At first, it could see everything I had in assets/css/app.css, but I was getting compilation errors that it couldn’t see the css files I was importing in app.css (e.g. phoenix.css and other import files listed below):
@tailwind base;
@tailwind components;
@tailwind utilities;
@import "./phoenix.css";
@import "./custom.css";
@import "./components/buttons.css";
So I started trying to modify those paths, but I noticed that the priv/static/assets/app.css file NEVER changed. So then I tried to delete
priv/static/assets/app.css to force it to regenerate, but nothing is happening. And of course now my app is choking because there is no app.css at all. Sigh.
I’m using mix phx.server to rebuild. Should I be using another command to make it rebuild the static assets? Is there an esbuild command to make that happen?
Here are the versions of things I’m using:
defp deps do
[
{:bcrypt_elixir, "~> 2.0"},
{:phoenix, "~> 1.6.6"},
{:phoenix_ecto, "~> 4.4"},
{:ecto_sql, "~> 3.7"},
{:postgrex, ">= 0.0.0"},
{:phoenix_live_view, "~> 0.17.1"},
{:floki, ">= 0.27.0", only: :test},
{:phoenix_html, "~> 3.0"},
{:phoenix_live_reload, "~> 1.3.3", only: :dev},
{:phoenix_live_dashboard, "~> 0.6.2"},
{:telemetry_metrics, "~> 0.6"},
{:telemetry_poller, "~> 0.5"},
{:esbuild, "~> 0.3", runtime: Mix.env() == :dev},
{:gettext, "~> 0.11"},
{:jason, "~> 1.2"},
{:plug_cowboy, "~> 2.5"},
# {:phx_gen_auth, "~> 0.7.0", only: [:dev], runtime: false},
{:nimble_csv, "~> 1.1.0"},
{:geo, "~> 3.4"},
{:poison, "~> 4.0"},
{:geo_postgis, "~> 3.4"}
]
end
Here is my dev.exs endpoint watchers configuration:
watchers: [
# Start the esbuild watcher by calling Esbuild.install_and_run(:default, args)
esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]},
npx: [
"tailwindcss",
"--input=css/app.css",
"--output=../priv/static/assets/app.css",
"--postcss",
"--watch",
cd: Path.expand("../assets", __DIR__)
]