0

Still learning Symfony. I've a generic theme based on bootstrap bought to be applied on our application. This theme contains javascripts, less/css files, images and fonts.

I'm using assetic and i'm trying to figure which is the best practice of including this theme in the application.

Should i put all the files in a subfolder of app\Resources\public?

app/Resources/public/mytheme 
app/Resources/public/mytheme/css 
app/Resources/public/mytheme/js
app/Resources/public/mytheme/images

But then, especially for images, i'd have to refer to files in twig by something like

{% image '../app/Resources/public/mytheme/images/user/no-image.png' output="images/user/no-image.png"%} 
    <img src="{{ asset_url }}" alt="Example"/>
{% endimage %}

It doesn't install any symlink or asset by using

php bin/console asset:install --symlink

And in a css i have the ".logo" class that has a reference to "app/Resources/public/mytheme/images/theme-logo.png" that in html results in a broken link even with a cssrewrite filter.

Should i create a MyThemeBundle that contains all the assets? Or should i put all the assets in web/mytheme folder (but all the assets will be public even less files)?

I'm a bit confused.

4

1 回答 1

1

完整阅读此页面:
http ://symfony.com/doc/current/assetic/asset_management.html#include-css-stylesheets

了解如何使用 cssrewrite 过滤器,从您的 css 内部正确指向您的图像

于 2017-07-05T09:32:36.107 回答