Assetic: Use CssMin filter

Discuss Symfony 2 bundles here

Moderators: tiagojsag, dcobalt

Assetic: Use CssMin filter

Postby DevDavid » Tue Apr 03, 2012 8:54 pm

Everywhere on the web are pages how the YUI Compressor could be used on e.g. CSS files. But nowhere is something how the also built-in CssMinFilter could be used?

My current template code looks like that:

Code: Select all
{% stylesheets output="/css/demo.css" debug=false
    'design/css/*'
%}
    <link href="{{ asset_url }}" rel="stylesheet" media="screen" />
{% endstylesheets %}


I want to minify my CSS with Assetic\Filter\CssMinFilter.
DevDavid
Junior Member
 
Posts: 1
Joined: Tue Apr 03, 2012 8:52 pm

Re: Assetic: Use CssMin filter

Postby Czechnology » Mon Jul 16, 2012 4:16 pm

...anyone knows how to set this up?

I modified my congig like this:
Code: Select all
assetic:
    debug:          %kernel.debug%
    use_controller: false
    filters:
        cssrewrite: ~
        cssmin:     ~


but then I get an error:
Fatal error: Class 'CssMin' not found in C:\Apache2\htdocs\...\vendor\assetic\src\Assetic\Filter\CssMinFilter.php on line 71


How exactly should I set up my config? I couldn't find any docs on this.
Czechnology
Junior Member
 
Posts: 24
Joined: Sat Feb 26, 2011 4:27 pm
Location: Prague / Vienna

Re: Assetic: Use CssMin filter

Postby dcobalt » Fri Jul 20, 2012 9:04 pm

Assetic has several filters, but includes no external libraries out of the box. You'll need to get CSSMin http://code.google.com/p/cssmin and integrate it into your project, much as you probably did with Gaufrette, Imagine, BaseFacebook for FOSFacebookBundle, or other similar ones (even Assetic counts) etc.

In case you don't know what I'm talking about, just do the following:
- get cssmin-v3.0.1.php (the latest version) from the link I posted
- rename it to cssmin.php and put it in vendor/cssmin/src inside your project
- Check out your autoload.php, add the following line in the list of registered namespaces:
Code: Select all
    'CssMin' => __DIR__.'/../vendor/cssmin/src',


This -should- work. I think. I haven't tried it.
dcobalt
Faithful Member
 
Posts: 283
Joined: Thu Oct 20, 2011 6:06 pm


Return to Bundles discussion

Who is online

Users browsing this forum: No registered users and 2 guests