Why part_1.js, part_2.js appears in my compiled code

When I compile my code using assetic, my js files are called part_1.js, part_2.js. I do not see this referent in part_ anywhere in my code. where does this happen?

config.yml

assetic:
     assets:
         our_custom_js:
            inputs:
                - '@MyBundle/Resources/public/js/base.js'
            filters:    []
            output: 'custom.js'
         fos_js_routes:
             inputs:
                 - 'bundles/fosjsrouting/js/router.js'
             output: 'fos_js_router.js'`    

base.html.twig

{% javascripts combine=false output="sandbox.js"
    '@our_custom_js'
    '@fos_js_routes'        
%}
    <script src="{{ asset_url }}"></script>
    <script src="{{ path('fos_js_routing_js', {"callback": "fos.Router.setData"}) }}"></script>

{% endjavascripts %}

my source looks like this:

<script src="/sandbox_part_1.js"></script>
<script src="/js/routing?callback=fos.Router.setData"></script>
<script src="/sandbox_part_2.js"></script>
<script src="/js/routing?callback=fos.Router.setData"></script>

This question has also been asked here. How to make the compilation of Symfony 2 assets a product of different file names?

+4
source share
1 answer

Just answered the same question here . The string 'part_ #' is added when accessing your application in the development environment ( app_dev.php).

{% javascripts %} /, <script> script. .

{% javascripts %} foreach dev, <script> . PHP- script , , foreach:

<?php foreach ($view['assetic']->javascripts(
    array(
        '@AppBundle/Resources/public/js/*',
        '@AcmeBarBundle/Resources/public/js/form.js',
        '@AcmeBarBundle/Resources/public/js/calendar.js',
    )
) as $url): ?>
    <script src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach ?>

base.html.twig :

{% javascripts combine=false output="sandbox.js"
    '@our_custom_js'
    '@fos_js_routes'        
%}
    <script src="{{ asset_url }}"></script>
{% endjavascripts %}
    <script src="{{ path('fos_js_routing_js', {"callback": "fos.Router.setData"}) }}"></script>

<script> javascripts, , .

+1

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


All Articles