Skip to content

I must use asset-map:compile to see modification #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
LewisSama opened this issue Nov 22, 2024 · 14 comments
Open

I must use asset-map:compile to see modification #77

LewisSama opened this issue Nov 22, 2024 · 14 comments

Comments

@LewisSama
Copy link

Hi !

I'm using the template from dunglas/symfony-docker. I followed the instruction to build/launch my container and installed the bare minimum according to documentation:

Twig:

  • symfony/twig-bundle

Asset-mapper:

  • symfony/asset-mapper
  • symfony/asset
  • symfony/twig-pack

Tailwindbundle:

  • symfonycasts/tailwind-bundle

After installing those according to documentation, i created a simple controller to use my twig file but i encounter an 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").

Even after running php bin/console tailwind:build, the error persists.
The only way to stop this error is to compile using asset-map:compile.

Afterward, every change i've made and built are not applied even when i use the --poll and i must rerun asset-map:compile to see any modification.

As it is very inconvenient to use asset-map:compile at every change, i wanted to know if there is anyway to make my tailwind:build --watch works.

Also, it's my first issue on GitHub so if there is any modification to make or precision, please tell me.

@weaverryan
Copy link
Contributor

Could be related: 81c9e6f - make sure (for now) that Tailwind 3 is being downloaded

@Dameen-Rainer
Copy link

I'm facing similar problem, when I add or edit classes in my 'main/homepage.html.twig' template, tailwind:build -w doesn't show any rebuilding changes & the browser doesn't reflect those classes' changes as well.
I always have to make some changes to another template classes, so tailwind:build -w and browser can reflect those changes.

@thinway
Copy link

thinway commented Feb 11, 2025

I'm facing the same issue, even working with Tailwind v3.4.17. The only way to make the new changes work is running asset-map:compile

@kbond
Copy link
Contributor

kbond commented Feb 11, 2025

Is everyone experiencing this issue using docker?

@thinway
Copy link

thinway commented Feb 11, 2025

yes, I'm using docker

@MatthieuLeVerger
Copy link

I'm facing the exact same issue, also using Tailwind v3.4.17, did one of you found a solution except using asset-map:compile ?

@Sh3nl0ng
Copy link

Sh3nl0ng commented Mar 8, 2025

I'm using the https://github.com/dunglas/symfony-docker boilerplate, and experiencing this issue.

@kbond
Copy link
Contributor

kbond commented Mar 8, 2025

Ok, pretty sure this issue is docker-specific. I don't use this in docker myself so I'll need some help here.

@Sh3nl0ng
Copy link

Sh3nl0ng commented Mar 9, 2025

For my case, this appears to be an issue with the /var folder not being mapped into the container by default.

By adding ./var:/app/var to my volumes definition in the compose.override.yaml I was able to resolve this issue.

# compose.override.yaml

# Development environment override
services:
  php:
    build:
      context: .
      target: frankenphp_dev
    volumes:
      - ./:/app
      - ./frankenphp/Caddyfile:/etc/caddy/Caddyfile:ro
      - ./frankenphp/conf.d/20-app.dev.ini:/usr/local/etc/php/app.conf.d/20-app.dev.ini:ro
      # If you develop on Mac or Windows you can remove the vendor/ directory
      #  from the bind-mount for better performance by enabling the next line:
      # - /app/vendor
      - ./var:/app/var
    environment:
      MERCURE_EXTRA_DIRECTIVES: demo
      # See https://xdebug.org/docs/all_settings#mode
      XDEBUG_MODE: "${XDEBUG_MODE:-off}"
    extra_hosts:
      # Ensure that host.docker.internal is correctly defined on Linux
      - host.docker.internal:host-gateway
    tty: true

###> symfony/mercure-bundle ###
###< symfony/mercure-bundle ###

###> doctrine/doctrine-bundle ###
  database:
    ports:
      - "3306"
###< doctrine/doctrine-bundle ###

Shoutout to this comment I came across on Symfonycasts.

Caveat - The /var folder is purposefully included in the .dockerignore folder to improve performance of your containers. If you notice performance issues related to this change you can target the /var/tailwind instead of the entire /var folder.

@SaraTerrier
Copy link

I'm not using Docker but I still have the same issue. I need to compile everytime I want to see changes on my web page.

@weaverryan
Copy link
Contributor

Hi everyone!

We can't replicate, but I can give more info, then I'm hoping someone who is having the issue can debug:

It’s confusing because we have to compile commands (tailwind and asset mapper), both in watch mode.

Let’s assume (which I think is the case) that tailwind’s watch mode is working. In that case, the problem is asset mapper’s watch not seeing the changes to the built tailwind file, which lives in the var/ directory.

I did see someone comment on mapping var/ in docker for this to work. I'd be curious if that fixes the issue for other docker users.

For all situations: what happens if you touch or manually modify the built tailwind file in var/? Does asset-mapper:build's watch see that change? Do you see the changes in your browser without needing to restart the asset-mapper:build command?

Finally if var/ for some reason is causing trouble, we could try storing the built tailwind file in a /tmp/ OS directory. I can't remember if there is a requirement that the built file live IN the project, but it may be worth a shot

@joelbeckmann
Copy link

I had the exact same problem. My solution was to delete the public/assets folder. Afterwards the folder is no longer created and my modifications get recognized directly.

I still get the issue when I run asset-map:compile because then the public/assets folder gets recreated. I assume symfony first looks in there for the css file and tailwind doesn't replace the css file in the public/assets directory.

I hope it helps someone. I am also not using docker for development.

@SaraTerrier
Copy link

I had the exact same problem. My solution was to delete the public/assets folder. Afterwards the folder is no longer created and my modifications get recognized directly.

I still get the issue when I run asset-map:compile because then the public/assets folder gets recreated. I assume symfony first looks in there for the css file and tailwind doesn't replace the css file in the public/assets directory.

I hope it helps someone. I am also not using docker for development.

Thanks that was the solution ! Deleting the public/assets folder and only using symfony server:start and php bin/console tailwind:build --watch works afterwards.

@kbond
Copy link
Contributor

kbond commented Mar 16, 2025

Ok, looks like this is an asset-mapper thing rather than a tailwind-bundle thing.

Basically, public/assets shouldn't exist in dev to allow for asset mapper's request subscriber to work correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants