I am a back end programmer, and looking forward to team up with a front end guy. He likes to do plain CSS, so tailwind is not an option, as I want to make the process as frictionless as possible.
I’ve saffolded an app with mix phx.new --no-tailwind and figured out there is no CSS anymore in the assets folder…
There is one in the priv/static/assets folder, though. I am used to have this file being overwritten by phoenix, and thus not include it in the git repo. It seems to me though that there is no other CSS in the project, so I am wondering if my partner should write directly in that file, and thus have it included in the git repo.
Is that the way to go in our context? Feels odd a little not having it in the assets folder…
For plain CSS I recommend you and your fellow frontend guy to try Lightningcss. Here’s how it can be configured:
Install Lightningcss inside assets/ directory.
cd assets/ && npm install --save-dev lightningcss
Specify browserlist option in assets/package.json.
{
"browserslist": [
"since 2022-12-01"
],
...
}
Add lightningcss tasks to mix.exs.
defp aliases do
[
...,
lightningcss:
"cmd npm exec --prefix assets -- lightningcss assets/styles/*.css --output-dir ./priv/static/styles --browserslist --nesting",
# for production
"lightningcss.minify": "lightningcss --minify",
"assets.deploy": ["lightningcss.minify", ..., "phx.digest"]
]
end
For development I use watchexec as it doesn’t leave zombie processes after closing a dev server. Watchexec should be installed and added to the Phoenix Watchers list in config/dev.exs.