2

I have some troubles making UglifyCSS and UglifyJS works with Assetics on my Symfony2.6 app.

I simplified a little the problem for the moment (I properly checked that I still meet the issue with this config). I import my stylesheet in my base twig file like this:

{% stylesheets
    '@main_css'
    output='assets/app.min.css'
%}
        <link rel="stylesheet" href="{{ asset_url }}"/>
{% endstylesheets %}

My assetic is configured with the UglifyCSS and with the filters cssrewrite and uglifycss. The filters are configured be applied to all .css files.

Here is my configuration:

# app/config/config.yml

assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    bundles:        ['MyFrontBundle']
    node:           /usr/local/bin/node
    node_paths:
        - "%kernel.root_dir%/../node_modules"
        - "/usr/local/lib/node_modules"
    filters:
        cssrewrite:
            apply_to: "\.css$"
        uglifycss:
            bin:      %kernel.root_dir%/../node_modules/.bin/uglifycss
            apply_to: "\.css$"
#        uglifyjs2:
#            bin:      %kernel.root_dir%/../node_modules/.bin/uglifyjs
#            apply_to: "\.js$"
    assets:
        main_css:
            inputs:
                - '@MyFrontBundle/Resources/public/css/app.min.css'

Here is the error:

$ php app/console assetic:dump
Dumping all dev assets.
Debug mode is on.

18:52:42 [file+] /path/to/app/../web/assetic/main_css.css



  [Symfony\Component\Process\Exception\RuntimeException]  
  The process has been signaled with signal "6".          



assetic:dump [--forks="..."] [--watch] [--force] [--period="..."] [write_to]

If I comment the uglifycss filter in my config, there is no longer any problem. Also, if I apply the filter directly into the stylesheet block, there is no problem too. So the problem comes from the apply_to declaration but I don't see why.

Oh yeah, I tried too by adding the filter manually the filter to the stylesheet block:

{% stylesheets
    '@main_css'
    filter="?uglifycss"
    output='assets/app.min.css'
%}
        <link rel="stylesheet" href="{{ asset_url }}"/>
{% endstylesheets %}

And then everything works fine. So in the ends it really comes down to using the apply_to to apply the filter.

I have exactly the same problem with uglifyjs. I checked beforehand all the paths: node, bin to uglify.

Thanks.

Théo
  • 655
  • 7
  • 17
  • Check this out http://symfony.com/doc/current/cookbook/assetic/asset_management.html `Notice that in the original example that included JavaScript files, you referred to the files using a path like @AcmeFooBundle/Resources/public/file.js, but that in this example, you referred to the CSS files using their actual, publicly-accessible path: bundles/acme_foo/css. You can use either, except that there is a known issue that causes the cssrewrite filter to fail when using the @AcmeFooBundle syntax for CSS Stylesheets.` – smarber Jan 08 '15 at 00:09
  • I'm sorry I didn't get you're answer. I'm not using the `bundles/acme_foo/css`absolute path but the `@AcmeFooBundle`. I understand the known issue you're talking about and I will take it into consideration. Still I fail to see how it's related to my issue. The problems doesn't comes from a wrong `url` link in my CSS, but from the fact that using the `apply_to` to apply the filters to all JS/CSS files fails and that it becomes impossible to dump my assets. – Théo Jan 08 '15 at 03:36

0 Answers0