SymfonyCasts / tailwind-bundle

Delightful Tailwind Support for Symfony + AssetMapper
https://symfony.com/bundles/TailwindBundle/current/index.html
MIT License
75 stars 16 forks source link

Working with multiple entrypoints #46

Open Gerben321 opened 7 months ago

Gerben321 commented 7 months ago

Hey,

I wanted to try out assetmapper and had to use this bundle. I couldn't understand why my error entrypoint (used for testing) didn't get any styling. I tried my main entrypoint (app.js and app.css) and that works fine.

So how do I get my other entrypoints working? I tried this config: symfonycasts_tailwind: input_css: 'assets/styles/error.css' But that breaks my normal entrypoint. I want to keep my stuff separated, thanks.

Gerben321 commented 6 months ago

Any solution? Sadly asset mapper is no working solution for me now.

bocharsky-bw commented 6 months ago

Hey @Gerben321 ,

Unfortunately, input_css is a scalar node so you can set it only to a single path, it does not support array of input css files. I suppose you're looking for something like:

symfonycasts_tailwind:
    input_css:
        - 'assets/styles/other.css'
        - 'assets/styles/error.css'

Do you want to give it a try to implement this feature?

Gerben321 commented 6 months ago

That's exactly what I'm looking for yes. For now I've moved further away from Asset mapper with many Symfony UX features that are very experimental with Asset mapper, or don't work. So I'm not sure if I will try it again. But I could give it a shot if I got some time left with a blank project.

kevincerro commented 5 months ago

I'm having the same issue

I have 2 entrypoints, app and status

Tailwind works when using app entrypoint, but not when using status

kevincerro commented 5 months ago

I'm having the same issue

I have 2 entrypoints, app and status

Tailwind works when using app entrypoint, but not when using status

Finally we migrated to webpack encore bundle while this is improved. We need multiple entrypoints

adeys commented 3 months ago

Hey @Gerben321 ,

Unfortunately, input_css is a scalar node so you can set it only to a single path, it does not support array of input css files. I suppose you're looking for something like:

symfonycasts_tailwind:
    input_css:
        - 'assets/styles/other.css'
        - 'assets/styles/error.css'

Do you want to give it a try to implement this feature?

Hello @bocharsky-bw. Can we still propose an implementation for this ?

bocharsky-bw commented 3 months ago

Hey! If users need this feature - I'm not against adding it, PRs are always welcome. Do you want to try to implement it?

adeys commented 3 months ago

Great. Yes I'll submit a PR for this.

OcB974 commented 2 weeks ago

Hello :)

I had a problem when I used several css files in my assets/styles (app.css & admin.css for example), and it compiled the app.css file each time. I use symfony's AssetMapper

While testing, I created the yaml file symfonycasts_tailwind.yaml with this configuration in the config/package folder

symfonycasts_tailwind:
    input_css:
        - '%kernel.project_dir%/assets/styles/app.css'
        - '%kernel.project_dir%/assets/styles/admin.css'

Except that in the config/package folder it didn't work, and when I installed the bundle I didn't have the file.

To get around this while waiting for a fix, I had to put it in my services.yaml file. And now it works, with symfony's AssetMapper.

With the command :

symfony console tailwind:build
symfony console tailwind:build assets/styles/admin.css 

First command compiles the file into app.built.css (the default) and Second command it compiles the admin.build.css file for me.

bocharsky-bw commented 2 weeks ago

This bundle has good defaults and you don't need to change the config often. That's why no symfonycasts_tailwind.yaml file is created, this bundle just does not have a Flex recipe. If you need to tweak the default config - you have to create the config file manually and put the config you want, see the docs for available configuration

NodokaMurmevent commented 1 week ago

Hello i try to configure like this (i use AssetMapper) :

symfonycasts_tailwind:
  input_css:
    - '%kernel.project_dir%/assets/styles/app.css'
    - '%kernel.project_dir%/assets/styles/wheel.css'
    - '%kernel.project_dir%/assets/styles/quiz.css'

but it’s doing nothing, all the files are ignored when i use php bin/console tailwind:build --watch

i have the last version of your bundle. Something seam to be broken.

adeys commented 1 week ago

Hello @NodokaMurmevent

Currently, when using the --watch flag, you need to explicitly specify each input CSS file you want to watch, as the Tailwind binary does not support watching multiple files simultaneously. If no input file is provided, only the first file is considered.

In your case, you’ll need to run three separate commands—one for each CSS file you want to watch. I'll look into improving this experience in the future if possible. Thanks for your understanding!

NodokaMurmevent commented 1 week ago

Ok! Thanks for your explanation, I will just merge all my CSS files into one app.css, it’s not a big deal, I can wait. It’s not forbid me to split my JS file.

Thanks for your bundle and all your work, I use it every day.