Symfony assets relative to bundle

1.2k Views Asked by At

EDIT | http://symfony.com/doc/current/assetic/asset_management.html#assetic-cssrewrite

So does this mean I absolutely have to upload the CSS assets into "web" myself? Is there not a way to use assetic:dump to copy them from the bundle first?

I have an application which is divided multiple smaller application via bundles.

One bundle in particular is an attempt to integrate a legacy app into symfony to run the same platform as a few other apps.

This LegacyBundle has JS and CSS assets which I do not want manually uploaded into "web" - I was under the impression that using assetic allowed me to have the CLI tools compress and re-locate the assets into the web directory.

This seems to be the case using @LegacyBundle prefix on the asset paths:

{% block javascripts %}
    {% javascripts 
        '@LegacyBundle/Resources/legacy/common/extjs/ext-all.js' 
    %}
    <script src="{{ asset_url }}"></script>
    {% endjavascripts %}
{% endblock %}

Problem is - I need this same functionality with CSS files and apparently there is an issue using @ shortcut with CSS files and assetic:

http://symfony.com/doc/current/assetic/asset_management.html

Notice that in the original example that included JavaScript files, you referred to the files using a path like @AppBundle/Resources/public/file.js, but that in this example, you referred to the CSS files using their actual, publicly-accessible path: bundles/app/css. You can use either, except that there is a known issue that causes the cssrewrite filter to fail when using the @AppBundle syntax for CSS stylesheets.

So I am trying to avoid using @LegacyBundle syntax for both JS and CSS - however I still wish to reference their paths in twig using the path relative to the bundle - where they go after that is of no concern to me.

What am I missing? Is what I am trying to do possible?

I tried moving ext-alljs.js into the bundle "Resources" root directory and then inside twig template I call the assets via

{% block javascripts %}
    {% javascripts 
        'Resources/ext-all.js' 
    %}
    <script src="{{ asset_url }}"></script>
    {% endjavascripts %}
{% endblock %}

Unfortunately this doesn't work - whereas the previous example does. I am hoping I just have the path incorrect or something?

0

There are 0 best solutions below