-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Dev mode for assetmapper does not serve css files automatically #54520
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
Comments
@cooldude77 With Symfony 6.4 or 7.0 you should be able to use the AssetMapper dev server and I created a small repro based on a fresh install and with 2 CSS files https://github.com/smnandre/repro-asset-css-dev Maybe that will help you see if you're doing something differently ? |
Thanks for the reply and repo |
Oh you may have a custom rule in your virtualhost to serve .css file directly maybe ? |
@smnandre Thanks for your reply. I haven't added any custom rule as it is bare bones apache2 ,php8.3 and mariadb installation on Ubuntu, running on a virtual box on windows 11. |
Could you share the content of your virtualhost ? I'm sorry "custom" was not the good word :) But i think there is something in the Apache config (probably in the default one) that does not send to the public/index.php requests containing ".css" |
No problem. https://pastebin.com/8QshmksR ( not to pollute this issue with code) Let me know if you need complete virtual box because I will need to check them before I send them to you. Thanks |
Nothing here, maybe in the site-enabled/XXX-your-local-domain ? (can be 000-default or somthing like that if you did not add yourself one) |
Hey Simon, Please have a look. |
Well nothing here seems to have an impact on this i'm sorry .... last chance, do you have a .htaccess in your public directory ? (or the parent one) ? |
Nope. I haven't reached to the level on development where I use .htaccess. All my urls for dev always have /public/index.php/{other routes} . I do plan to use .htaccess soon but since it is not immediately necessary , my project does without it. Thanks |
Ok... then that's it... i'm very sorry for the long road :/ AssetMapper does indeed not work without URL rewriting at the moment.. |
Hey,
I am not sad for it not to work, infact I am quite happy that I now can
focus on finding other ways (using controllers) with your confirmation.
Maybe there will be a path in future to see this developed.
Thanks a lot for taking your time out of your busy schedule and being
patient about it. Really appreciate and thanks again.
Ashvini
…On Sat, 13 Apr, 2024, 23:20 Simon André, ***@***.***> wrote:
All my urls for dev always have /public/index.php/
Ok... then that's it... i'm very sorry for the long road :/
AssetMapper does indeed not work without URL rewriting at the moment..
—
Reply to this email directly, view it on GitHub
<#54520 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAUKDYOPCCPBKVPAYBBYATLY5FV6XAVCNFSM6AAAAABF4EU6J6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJTG4YTIOJYGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Thank you for this message :) |
@smnandre, could you please elaborate on your comment:
Isn't this something that could be handled by a web server such as Apache or NGINX? If I knew what the rules were I would like to try do this myself. Could you share them with me? Thank you |
@nialltiernan I'm sorry i'm not sure to fully understand.. :) What i meant by this quote is: the AssetMapper Dev Server simulates "prod" conditions by responding to requests and returning assets, using the same URL the assets would have in prod (ex: /assets/images/foo-12346ab.png) As of today, this does not work when URL rewriting* is not enabled locally (something that the symfony-cli does out of the box or every docker local instal provides) * i used the term "url rewriting", another way could be "forward every http request in a given directory to a PHP front controller" In production, with a webserver the dev server is disabled and AssetMapper "only" compile and deploy your assets in the assets folder. What problem are you facing currently ? Is there something in particular you would need help ? |
So now it's impossible to run DEV env on a webserver without cli tools? |
run |
I have nginx... |
No one ever told this :)
Nginx configuration is detailed here: https://symfony.com/doc/current/setup/web_server_configuration.html#nginx |
But it is (from the box).
There are no any mention about rewrite rules or I can't see it |
I ran into the same issue in dev where assets were returning a 404 due to nginx config. The offender was
A useful config in production, but in dev, it means assets are served directly (which was not obvious to me), bypassing symfony's listener to rewrite the path. Would it be worth mentioning this in the doc ? |
Hey, thanks for your report! |
Hi, |
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected
6.3.12, 7.0.6
Description
Hello Helping folks,
I am coding my app with version 7.0.6 and saw asset mapper being used for delivering CSS.
I added app.css as mentioned in the assets folder of the project.
I am running a simple installation of apache2, php 8.3, mariadb on Ubuntu environment on virtual box
As mentioned here , the assets should be delivered to the web page using an inbuilt controller if the APP_ENV=dev and I don't have to compile them.
Unfortunately, I do not see the assets being delivered to web page in dev environment.
To mitigate it , I compiled the assets ( shouldn't need to ) in dev environment and files were added to my public folder.
I thought maybe I am not doing something correct so I purchased the course given at symfonycast in dev environment but to no luck.
What am I doing wrong here? or is some step missing?

Thanks a lot.
How to reproduce
Create any symfony project where asset mapper can be used ( please use dev mode)
Install symfony
Update/create assets/style/app.css and then change some values in css.
The css is not reflected on page load and the upon clicking the js file leads to 404 ( because it is not in public folder)
Possible Solution
Update:
Just found out after lot of debugging and researching, this only works good when we are using symfony local server run using command
symfony server:start
Is there anyway to run it using configurations above( using apache) ?
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: