Tailwind stylesheets are not generated for stylesheets other than `app.css`
The problem
If you define more than one input_css path in the config/packages/symfonycasts_tailwind.yaml configuration file, Tailwind stylesheets are not generated for that CSS inputs:
# config/packages/symfonycasts_tailwind.yaml
symfonycasts_tailwind:
input_css:
- assets/app/styles/app.css
- assets/orange-pizza/styles/orange-pizza.css
- assets/brave-elephant/styles/brave-elephant.css
Please see an example in the following repository: https://github.com/kniziol/TailwindBundle-and-AssetMapper
Steps to reproduce the issue
-
Clone https://github.com/kniziol/TailwindBundle-and-AssetMapper repo
-
Install DDEV. See more: Get Started
-
Run the following commands to start the project:
ddev composer installddev launch -
Go to https://symfony-asset-mapper-paths-separation.ddev.site/brave/elephant
-
See the error:
An exception has been thrown during the rendering of a template ("Built Tailwind CSS file does not exist: run "php bin/console tailwind:build" to generate it"). -
Run the command:
ddev console tailwind:buildSee output similar to this one:
! [NOTE] Downloading TailwindCSS binary from https://github.com/tailwindlabs/tailwindcss/releases/download/v3.4.17/tailwindcss-linux-arm64 40525732/40525732 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% ! [NOTE] Executing Tailwind (pass -v to see more details). Rebuilding... Done in 90ms. -
Refresh the page: https://symfony-asset-mapper-paths-separation.ddev.site/brave/elephant
-
Unfortunately, the error still exists 👇
More information
Stylesheet for the app entrypoint has been generated only:
ls -alh var/tailwind/
total 24
drwx------@ 4 kn staff 128B Jan 5 19:00 .
drwx------@ 5 kn staff 160B Jan 5 18:59 ..
-rw-------@ 1 kn staff 10K Jan 5 19:00 app.built.css // <------- Here
drwx------@ 3 kn staff 96B Jan 5 19:00 v3.4.17
I expected stylesheets generated for all CSS inputs defined in the configuration file:
# config/packages/symfonycasts_tailwind.yaml
symfonycasts_tailwind:
input_css:
- assets/app/styles/app.css
- assets/orange-pizza/styles/orange-pizza.css
- assets/brave-elephant/styles/brave-elephant.css
It looks like this is connected to https://github.com/SymfonyCasts/tailwind-bundle/issues/46
Workaround
Run the bin/console tailwind:build multiple times for each CSS stylesheet 👇
# For the assets/app/styles/app.css
ddev console tailwind:build
# For the assets/orange-pizza/styles/orange-pizza.css
ddev console tailwind:build assets/orange-pizza/styles/orange-pizza.css
# For the assets/brave-elephant/styles/brave-elephant.css
ddev console tailwind:build assets/brave-elephant/styles/brave-elephant.css
The same applies when we want to "watch" changes:
ddev console tailwind:build --watch
ddev console tailwind:build assets/orange-pizza/styles/orange-pizza.css --watch
ddev console tailwind:build assets/brave-elephant/styles/brave-elephant.css --watch
This behaviour is because of the reason explained here: https://github.com/SymfonyCasts/tailwind-bundle/issues/46#issuecomment-2326528767
So this is a problem upstream. If you have any ideas how to fix it - please, feel free to create a PR
I have a similar issue. I have two input files and can generate each one independently with separate commands successfully. But when I use asset-map:compile only for the first defined input file in the settings the built file will be copied. For the second one the non built version will be copied.