I make use of multiple css files in the website that I’m building, but I notice that live reload works only when I modify the app.css
file, while I would like for it to also work with the other css files.
This is the relevant config.exs
snippet:
# Configure tailwind (the version is required)
config :tailwind,
version: "3.4.3",
my_dummy_website: [
args: ~w(
--config=tailwind.config.js
--input=css/app.css
--output=../priv/static/assets/app.css
),
cd: Path.expand("../assets", __DIR__)
],
navigation: [
args: ~w(
--config=tailwind.config.js
--input=css/navigation.css
--output=../priv/static/assets/navigation.css
),
cd: Path.expand("../assets", __DIR__)
],
home: [
args: ~w(
--config=tailwind.config.js
--input=css/home.css
--output=../priv/static/assets/home.css
),
cd: Path.expand("../assets", __DIR__)
]
the relevant dev.exs
snippet:
watchers: [
esbuild: {Esbuild, :install_and_run, [:my_dummy_website, ~w(--sourcemap=inline --watch)]},
tailwind: {Tailwind, :install_and_run, [:my_dummy_website, ~w(--watch)]}
]
...
...
# Watch static and templates for browser reloading.
config :my_dummy_website, MyDummyWebsiteWeb.Endpoint,
live_reload: [
patterns: [
~r"priv/static/(?!uploads/).*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/my_dummy_website_web/(controllers|live|components)/.*(ex|heex)$"
]
]
and finally the relevant mix.exs
snippet:
defp aliases do
[
setup: ["deps.get", "assets.setup", "assets.build"],
"assets.setup": ["tailwind.install --if-missing", "esbuild.install --if-missing"],
"assets.build": [
"tailwind my_dummy_website",
"tailwind navigation",
"tailwind home",
"esbuild my_dummy_website",
],
"assets.deploy": [
"tailwind my_dummy_website --minify",
"tailwind navigation --minify",
"tailwind home --minify",
"esbuild my_dummy_website --minify",
"phx.digest"
]
]
end
I believe the problem to be the fact that, the watchers only watch my_dummy_website
and therefore trigger only the my_dummy_website
target in the snippet of config.exs
. I think that what should be done is somehow make navigation
and home
dependencies of my_dummy_website
, but I’m not sure how. I tried defining multiple input output pairs in the tailwind arguments but I found out that tailwind does not support that.
Does anyone know if what I’m asking for is possible? Thanks.