Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using icons with twitter bootstrap and assetic

I have assetic configured and working with the following config

assetic:
    assets:
        global:
            inputs:
                - '%kernel.root_dir%/Resources/public/less/global.less'
    debug:          %kernel.debug%
    use_controller: false
    #java: /usr/bin/java
    filters:
        cssrewrite: ~
        less:
            node:       /usr/local/bin/node
            node_paths: [/usr/local/lib/node, /usr/local/lib/node_modules]
            apply_to: "\.less$"

In my twig file I have the following which prints out the css file perfectly.

{% stylesheets filter='less,cssrewrite'
   '@global'
%}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" media="screen" />
{% endstylesheets %}

Here is my app/Resources/public/global.less file

@import "../../../../vendor/twitter/bootstrap/less/bootstrap.less";


/*
* Global Styles
*/
body{
    background: #333;
}

The issue is that I am not able to use the Twitter Bootstrap icons because they are 404. My images currently live at app/Resources/public/img/ I have tried everything to get these to work, and have tried every assetic command.

Do I need cssembed as mentioned here ? I sure hope I don't have to run Java to get this going.

like image 219
Mike Avatar asked Nov 14 '22 01:11

Mike


1 Answers

I founded a solution for this sometime ago, i don't know if is best way to do that, but it works. Just call your assets from the web/bundles instead from real location. Then, you must run first assets:install before assetic:dump. Your assetic configuration is equal to mine. I'm don't using less filter but i supposed that is aplicable too.

{% block head_style %}
{% stylesheets filter='yui_css, cssrewrite' 
        'bundles/bgcomun/css/bootstrap.css'
            'bundles/bgcomun/css/comun.css'
             output='css/compiled/main.css'


    %}
    <link href="{{ asset_url }}" type="text/css" rel="stylesheet"
          media="screen" />
{% endstylesheets %}
like image 149
smoreno Avatar answered Dec 19 '22 02:12

smoreno