tailwind-bundle icon indicating copy to clipboard operation
tailwind-bundle copied to clipboard

Tailwind stylesheets are not generated for stylesheets other than `app.css`

Open kniziol opened this issue 1 year ago • 4 comments

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

  1. Clone https://github.com/kniziol/TailwindBundle-and-AssetMapper repo

  2. Install DDEV. See more: Get Started

  3. Run the following commands to start the project:

    ddev composer install
    
    ddev launch
    
  4. Go to https://symfony-asset-mapper-paths-separation.ddev.site/brave/elephant

  5. 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").
    
  6. Run the command:

    ddev console tailwind:build
    

    See 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.
    
  7. Refresh the page: https://symfony-asset-mapper-paths-separation.ddev.site/brave/elephant

  8. Unfortunately, the error still exists 👇

TailwindBundle - Built Tailwind CSS file does not exist

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

kniziol avatar Jan 05 '25 18:01 kniziol

It looks like this is connected to https://github.com/SymfonyCasts/tailwind-bundle/issues/46

kniziol avatar Jan 05 '25 18:01 kniziol

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

kniziol avatar Jan 05 '25 21:01 kniziol

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

bocharsky-bw avatar Jan 06 '25 12:01 bocharsky-bw

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.

viu-x avatar Jun 08 '25 10:06 viu-x