0

I have an application that needs some assets from URL. I am importing them like:

{% block stylesheets %}
    {% stylesheets
        'http://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.css'
        'bundles/bmatznerfoundation/css/foundation.min.css'
        'bundles/arpanetkorepeteshop/css/*'
        filter="cssrewrite"
    %}
        <link rel="stylesheet" type="text/css" href="{{ asset_url }}" />
    {% endstylesheets %}
{% endblock %}

If I dump assets

php app/console assetic:dump

it downloads the source. But if there is some imports inside the source, it don't download it.

@font-face {
    font-family: "foundation-icons";
    src: url("http://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.eot");
}

Is there a way to download it all?

1
  • Maybe cssrewrite changed the url? Commented Sep 1, 2015 at 14:24

2 Answers 2

1

Short version: no. Parsing a CSS file for imports (in this case an external font file) is way beyond the scope of something like Assetic to be able to do. There are plenty of ways of hooking into Assetic if you're willing to dig around in the code and writing your own, however in this instance I would recommend just downloading the font icon pack yourself - you are after all bundling it yourself as a project dependency.

Sign up to request clarification or add additional context in comments.

Comments

0

No, the CSS is parsed at page load time, so the browser will do the downloading, not assetic. But here's a suggestion:

Instead of adding the URLs to all of your stylesheets block, you could also define them as assets in your config (YML in my case), and then just include the assets you need in your stylesheets block.

# Assetic Configuration
...
...
assets:
    foundation_icons:
        inputs:
          - //cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.css
        output: css/foundation_icons.css
    jquery:
        inputs:
            - %kernel.root_dir%/../vendor/jquery/jquery/jquery-2.1.3.js
            - //ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js
        output: js/jquery.js
    datatables:
        inputs:
            - //cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js
        output: js/datatables.js

Then in your stylesheets block, just call

{% stylesheets
    '@foundation_icons'
    'bundles/bmatznerfoundation/css/foundation.min.css'
    'bundles/arpanetkorepeteshop/css/*'
%}

you can now load @foundation_icons in any view, and dont need to be copying any URLs.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.