// composer.json
{
"require": {
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"knplabs/knp-time-bundle": "^2.2", // v2.4.0
"php-cs-fixer/shim": "^3.46", // v3.46.0
"phpdocumentor/reflection-docblock": "^5.3", // 5.3.0
"phpstan/phpdoc-parser": "^1.25", // 1.25.0
"symfony/asset": "7.0.*", // v7.0.3
"symfony/asset-mapper": "7.0.*", // v7.0.2
"symfony/console": "7.0.*", // v7.0.2
"symfony/dotenv": "7.0.*", // v7.0.2
"symfony/flex": "^2", // v2.4.3
"symfony/framework-bundle": "7.0.*", // v7.0.2
"symfony/http-client": "7.0.*", // v7.0.2
"symfony/monolog-bundle": "^3.0", // v3.10.0
"symfony/property-access": "7.0.*", // v7.0.0
"symfony/property-info": "7.0.*", // v7.0.0
"symfony/runtime": "7.0.*", // v7.0.0
"symfony/serializer": "7.0.*", // v7.0.2
"symfony/stimulus-bundle": "^2.13", // v2.13.3
"symfony/twig-bundle": "7.0.*", // v7.0.0
"symfony/ux-turbo": "^2.13", // v2.13.2
"symfony/yaml": "7.0.*", // v7.0.0
"symfonycasts/tailwind-bundle": "^0.7.1", // v0.7.1
"twig/extra-bundle": "^2.12|^3.0", // v3.8.0
"twig/twig": "^2.12|^3.0" // v3.8.0
},
"require-dev": {
"symfony/debug-bundle": "7.0.*", // v7.0.0
"symfony/maker-bundle": "^1.52", // v1.53.0
"symfony/stopwatch": "7.0.*", // v7.0.0
"symfony/web-profiler-bundle": "7.0.*" // v7.0.2
}
}
7 Comments
Well, after changing from dev to prod I ended up with "Hey look at that: No CSS :("...
I think since asset mapper we have to manually build our assets in prod right?
Hey @elkuku ,
Did you try to clear the cache? Did you run all the required commands from the README file before start working with the start/ directory of the downloaded course code?
Cheers!
I doubt that clearing the cache would create the missing files but yes I ran the commands from the readme file (even the updated one...)
I am not sure what magic you have running on your end but as far as I understand the new asset mapper component it will only compile your assets in the dev environment while you have to run
bin/console asset-map:compileto have your assets available in prod.So.... What (the
F) am I missing here??Hey @elkuku ,
Sorry for confusing, I mean clear the browser cache, in Google Chrome you can do or while the Chrome dev tools panel is open, and you can press and hold the refresh browser button, then choose "Empty cache and hard reload". Though clearing the app cache is also a good idea, especially in prod as it may has some cached templates that were changed and so this may not include some necessary CSS files, etc. So I would recommend you both actually.
But once again, the steps you should do to boot the project with styles correctly:
composer installbin/console tailwind:build- this command is exactly the one that responsible for your styles look good, no matter of the Symfony env you're loading your app in.symfony serveorAPP_ENV=prod symfony servein case you want to run it in prodI just re-downloaded the course code myself again, moved to the finish/ dir, and followed all those steps from above. After this, when I load the app in the
prodmode - I do see styles, so no extra steps required for me.Which OS are you on? Are you following this course from the start/ dir? Are you using Symfony built-in dev server to spin the app? If your setup is a different one, probably you may have some misconfiguration.
Btw, you may want to rerun the
composer installcommand, does it fix the problem for you in prod? Becausecomposer.jsonhave some scripts that will be run during the install command. Or you can try to run them manually one by one to see if that will help.I hope this helps!
Cheers!
Hey @Victor,
Thanks for your detailed reply. Very much appreciated. Unfortunately I am still not able the find the error on my side :(
About my environment: I am running on a Linux system with the Symfony binary installed and I did exactly what is recommended in the readme file. Everything works just fine in the
devenvironment.I think I disagree on your point number 4. On my system the command
bin/console tailwind:buildwill build the CSS in/var/tailwind/tailwind.built.csswhich (I think) is somehow served by asset mapper in/public/assets/but only indev...When I switch to
prod(via the.envfile) I get a bunch of 404s trying to load the assets from/public/assetswhich does not exist until I do abin/console asset-map:compileafter which the site loads perfectly.But... I have noticed after several tests that sometimes the browser loads the assets from the cache after switching to
prodand sometimes.. notSooo.... All that I can think of at this point is that maybe your cache has not been cleared?
Please (please) correct me if I'm wrong ;)
Cheers!
Hey @elkuku ,
Ah, you're right, that's my browser's cache actually! I wonder if you're on Chrome too though, because it kinda should continue work well because of the browser cache. But indeed, when you manually clear the cache and do hard reload - the styles are gone. That's because the listener, IIRC
AssetMapperDevServerSubscriber, works only in dev mode. So, for prod, you indeed need to run an extra command:See more detailed information in Symfony docs: https://symfony.com/doc/current/frontend/asset_mapper.html#serving-assets-in-dev-vs-prod
Thanks for pointing it out, we will add a note about it.
Cheers!
I had the same issue!
Thanks for insisting ;-))
"Houston: no signs of life"
Start the conversation!