SymfonyCasts / tailwind-bundle

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

Watch + refresh does not update asset css #27

Closed back-2-95 closed 9 months ago

back-2-95 commented 11 months ago

I have watch mode running with in my Symfony 7.0.0-BETA3 project:

bin/console tailwind:build --watch

It will successfully build var/tailwind/tailwind.build.css with any changes to assets/styles/app.css.

BUT when refreshing the app in browser, changes don't get updated. When I check public/assets/styles/app-HASH.css it has not been updated.

In base.html.twig I have following inside

        {% block stylesheets %}
        {% endblock %}

        {% block javascripts %}
            {{ importmap('app') }}
        {% endblock %}

which will create following markup:

image

I also tried this as mentioned in the documention but to no luck:

{% block stylesheets %}
    <link rel="stylesheet" href="{{ asset('styles/app.css') }}">
{% endblock %}

So I need to manually run these to get CSS updated:

bin/console tailwind:build
bin/console asset-map:compile
back-2-95 commented 11 months ago

Issue remains.

when running bin/console tailwind:build --watch

I also checked that my Docker setup does not affect this. Same happens when I run that command on host and on container.

fracsi commented 11 months ago

@back-2-95 If you want to see the changes in the browser without compiling your assets every time after change, you should enable the "dev server" for the asset mapper (enabled by default only in "debug" mode) See: bin/console config:dump framework asset_mapper.server

When this "dev server" is enabled, assets are handled by symfony (they must not exist in the filesystem - remove publis/assets) - https://symfony.com/doc/current/frontend/asset_mapper.html#serving-assets-in-dev-vs-prod

back-2-95 commented 11 months ago

@fracsi Thank you very much, now I got it working! framework.asset_mapper_server: true was the key!

weaverryan commented 9 months ago

Cool! Glad this got solved!