tanGee
tanGee

Reputation: 573

Assetic not dumping certain files

In the main layout page for my Symfony2 project I have assetic blocks for CSS and JavaScript as follows:

{% block stylesheets %}
    {% stylesheets
        'bundles/my_bundle/css/main.css'
        'bundles/my_bundle/css/additional.css'
        'bundles/my_bundle/css/new.css'
        filter='cssrewrite'
        output='css/packed/layout_default.css'
    %}
    <link type="text/css" rel="stylesheet" href="{{ asset_url }}" />
    {% endstylesheets %}
{% endblock %}

{% block javascripts %}
    {% javascripts
        'bundles/my_bundle/js/main.js'
        'bundles/my_bundle/js/additional.js'
        'bundles/my_bundle/js/extra.js'
        output='js/packed/layout_default.js'
    %}
    <script type="text/javascript" src="{{ asset_url }}"></script>

    {% endjavascripts %}
{% endblock %}

There are also other files which contain these blocks as the project is a multi-theme enabled one.

Recently (without changing anything assetic-related) I have noticed that when I do

app/console assetic:dump

the command initially stalls for about 10 seconds, as if it is rebuilding a cache or something, and then begins to dump files. All .js files are dumped correctly, and all css files from the non-default themes.

However, sometimes the css files from the above blocks are not dumped, and the only way I have found to remedy this is to edit my layout page and remove one of the css files within the stylesheets block, run the dump command, add the stylesheet back in, and re-run the command. After doing this, subsequent assetic:dumps run properly, albeit still with the initial pause.

Has anyone experienced behaviour similar to this, or does anyone have any pointers as to where I can look to troubleshoot this further?

Upvotes: 3

Views: 8129

Answers (1)

Nicolai Fr&#246;hlich
Nicolai Fr&#246;hlich

Reputation: 52483

i experienced similar behavior sometimes when only doing small changes like output-name to the asset collections ...

However clearing the cache prior to dumping always fixed the issue for me.

therefore i always execute:

app/console cache:clear --no-warmup && assetic:dump --no-debug

and have aliased this to s ca:c in my zshrc.

I advise you to use pre-configured asset collections in your config.yml ( or an imported file ) as i mentioned in this answer. This really compacts your templates and makes them more readable.

Upvotes: 8

Related Questions