Reputation: 3374
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.
Upvotes: 5
Views: 1008
Reputation: 2827
I don't see why you can't use web/
folder for your assets.
I often work with less
and other file format which are afterward processed and minified.
The solution to your problem seems simple to me: Use two folder in the web/
folder.
The first folder would be your source/
folder. In which you would place all your sass
files. You will add a .htaccess
file to this same folder, and deny all access (you can copy from the .htaccess
file in the src/
folder).
Then a second folder, lets call it assets
which will hold all your compiled and minified assets.
That should do the trick... ;)
You may be interested in this topic as well. It may help to hide futher the existence of your source/
folder. ;)
If you really don't want to have your sources files in the web/
folder, then loot at this, it should help you place your sources files in your bundle.
Upvotes: 0
Reputation: 2034
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 :)
Upvotes: 7