I still have some problems to handle my assets in symfony. The best practices say, I should store my assets in web/
.
But I dont like to store my raw sass files there, because its a public folder and I think only compiled or static files should be stored there.
Thats why I store them (js and sass) currently in app/Resources
. And my assetic.read_from
is app/Resources
. But then there are some bundles, that are symlinked by assets:install
to web/bundles/
.
And now, when I want to include this bundle-assets in my twig files, I have to go there by ../../web/bundles/..
in the stylesheets block. That doesnt look very clean, so I did a symlink app/Resources/bundles->web/bundles/
and that works.
But I still think its too much fiddle and I would like to know if there is a cleaner way that better collects my assets in one place.
Don't use AsseticBundle, it was even removed in default symfony-standard 2.8. Managing frontend assets with php is workaround for someone who really don't want to use "the right tools"
I personally keep my source files in /assets/
and with Grunt JS I compile them to /web/assets/
which later is served from assets.somedomain.com
through CDN
2 years ago I wrote post about managing assets with symfony, it's still valid and up to date. You might want to check it out.
http://konradpodgorski.com/blog/2014/06/23/better-way-to-work-with-assets-in-symfony-2/
I should extend post by things I learned since then but always not enough time :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With