Phoenix different handling of some CSS files

Current Phoenix ships with a nicely working assets handling config, employing esbuild and tailwind. This is all extra cool now that we no longer need webpack and whatnot. I can add my custom, modularised CSS/JS into separate files, import them into wherever I need, etc. and things fly out of the box. Super cool. I have a probably slightly less common need though. I want some CSS files to remain unbundled into the main app.css and just automatically copy them over from assets/css/ to priv/static/assets/ on change/build. What would be the Phoenix idiomatic way to do it?

Phoenix normalized on just having files needing a build system be in assets. Non compiled stuff just lives in priv/static/ directly. But also watchers (in config/dev.exs) as well as the mix assets.* aliases (in mix.exs) can be extended to your likeing if you still wish to plain copy files around.

True, I could put those files directly in priv and I guess live_reload should work w/o changes (although need to check it) but for dev purposes I’d prefer having those files close together with the rest of CSS stuff. So at least the watchers and mix task(s) would need to be augmented. Would you be so kind as to give an example of how would you do it?

See Phoenix.Endpoint — Phoenix v1.7.14 and Mix — Mix v1.17.2. Consider mix cmd — Mix v1.17.2 to call a CLI from an alias.

OK, mix cmd looks good for copying stuff around :slight_smile: but I admit I have much more foggy understanding of how the watchers work. I understand from the docs that:

[I] can configure it to whatever build tool or command [I] want

but the example runs

the “watch” mode of the webpack build tool

which means the tool itself does the watching for changes, right? And If my “build tool or command” is the cp command?

A watcher can also be a module-function-args tuple that will be invoked accordingly:

[another: {Mod, :fun, [arg1, arg2]}]

But again - who does the watching for changes and how?

You’re correct. You need to bring your own (build tools usually come with those anyways). You could use file_system | Hex if you want something elixir.

I see, that makes some sense. The good thing is that it is already in the deps (due to live_reload I presume). I’ll have a closer look and report, TNX for now.