Symfony assetic with named assets double flushed to prod?

Assist management is the hardest part to understand IMHO, even after playing a year or more with Symfony. In any case, I experimented with registered assets :

assets:
    mybundle_front_js:
        inputs:
            - @MeMyBundle/Resources/public/jquery/dist/jquery.js
            - @MeMyBundle/Resources/public/bootstrap/js/affix.js
            - @MeMyBundle/Resources/public/bootstrap/js/alert.js
            - @MeMyBundle/Resources/public/bootstrap/js/button.js
            - @MeMyBundle/Resources/public/bootstrap/js/carousel.js
            - @MeMyBundle/Resources/public/bootstrap/js/collapse.js
            - @MeMyBundle/Resources/public/bootstrap/js/dropdown.js
            - @MeMyBundle/Resources/public/bootstrap/js/modal.js
            - @MeMyBundle/Resources/public/bootstrap/js/tooltip.js
            - @MeMyBundle/Resources/public/bootstrap/js/popover.js
            - @MeMyBundle/Resources/public/bootstrap/js/scrollspy.js
            - @MeMyBundle/Resources/public/bootstrap/js/tab.js
            - @MeMyBundle/Resources/public/bootstrap/js/transition.js
        filters: [?uglifyjs2]

Using a named resource:

{% block javascripts %}
    {% javascripts
        "@mybundle_front_js" %}
        <script src="{{ asset_url }}"></script>
    {% endjavascripts %}
{% endblock %}

Dropping them:

php app/console cache:clear --env=prod
php app/console assetic:dump --env=prod

The result is two files with the same contents of the same size:

%kernel.root_dir%/../web/assetic/mybundle_front_js.js
%kernel.root_dir%/../web/js/055a364.js

Is there a reason to create two identical files in a prod environment?

+4
source share
1 answer

The first file assetic/mybundle_front_js.jsis the resulting file from the configuration of the named resource. The second file is the resulting file used from the aseptic block inside your template.

:

{% block javascripts %}
    {% javascripts
        "@mybundle_front_js"
        "@whateveer" %}
        <script src="{{ asset_url }}"></script>
    {% endjavascripts %}
{% endblock %}

assetic/ js/, .

, assetic/: , {% javascripts %}.

+2

Source: https://habr.com/ru/post/1533966/


All Articles