4
votes

I'm new in symfony 2 and Assetic. I'd like use assetic and Sass for my CSS. I use Custom Fonts. I create in my bundle under Resources the folder "assets/css" and inside I have _base.scss and main.scss. In my public folder I have:

  • css
  • fonts
  • images
  • js

In fonts I have my custom fonts.

In my SCSS I retrive my fonts and my images like this:

    @include font-face("billabongregular", font-files("/bundles/Mybundle/fonts/billabong-webfont.ttf"));
background: $bg_header url("/bundles/Mybundle/images/darkGreyBackground.jpg") fixed no-repeat top center;

I have this path after assets:install, and I have my file under web/mybundle/fonts and web/mybundle/images

When I do php app/console assetic:dump --env=prod --no-debug

I have in my web:

  • css
  • js (folder in public)

But I haven't Fonts folder and images folders. If IO see the source code in images I have this path /bundles/Mybundle/images/darkGreyBackground.jpg

Why I haven't all folder in web? Is it right call my images and my fonts with /bundles/Mybundle/images/darkGreyBackground.jpg and /bundles/Mybundle/fonts/billabong-webfont.ttf?

2
Please stop editing your question to restore the horrible broken grammar. – meagar♦

2 Answers

1
votes

This is a standard and expected behavior to have the symbolic links of the resources of your bundle being under web/bundles/Mybundle/ after you call the php app/console assetic:dump command.

To use the assets generated path in your css, you can use the cssrewrite filter or even more simple, your css and images folders being in the same main folder, use relative path:

@include font-face("billabongregular", font-files("../fonts/billabong-webfont.ttf"));
background: $bg_header url("../images/darkGreyBackground.jpg") fixed no-repeat top center;

EDIT

In your bundle, if you want a file to be accessible in the web directory after your run the assets:install command, you have to put them inside the Resources/public/ directory as stated here: http://symfony.com/doc/current/book/page_creation.html#bundle-directory-structure

-1
votes

I had the same problem and I just tried using the following as a workaround. Seems to work so far.

{% stylesheets
    output='assets/fonts/glyphicons-halflings-regular.ttf'
    'bundles/bootstrap/fonts/glyphicons-halflings-regular.ttf'
%}{% endstylesheets %}

Notice the omission of any output which means nothing shows up on the template. When I run assetic:dump the files are copied over to the desired location and the css includes work as expected.