S
S
Sergey2015-07-13 12:20:04
symfony
Sergey, 2015-07-13 12:20:04

How to properly prepare assets for Symfony2 prod?

Here is the code for connecting scripts

{% block css %}
    {% stylesheets
    'assets/vendor/bootstrap/css/bootstrap.min.css'
    ...
    filter='cssrewrite' output='compiled/css/all.css' %}
    <link rel="stylesheet" href="{{ asset_url }}"/>
    {% endstylesheets %}
{% endblock %}

{% block js %}
    {% javascripts
    'assets/vendor/jquery/jquery.min.js'
   ...
    'assets/js/index.js'
    'assets/js/scripts.js'
    
    output='compiled/js/all.js' %}
    <script src="{{ asset_url }}"></script>
    {% endjavascripts %}
{% endblock js %}

I execute the command
rm -rf web/compiled/* && php app/console cache:clear -e=prod --no-warmup && php app/console assetic:dump -e=prod

As a result, I see the following
91e35a17ac.jpg
What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
WarGot, 2015-07-13
@WarGot

Try app/config/assetic.yml to describe what should be collected into what and which compressors to go through, and connect in the templates according to the resulting file or look at your assetic.yml assetic -> bundles block, it seems that ignored bundles are indicated here.

assetic:
    debug:          false # %kernel.debug%
    use_controller: false
    read_from:      %kernel.root_dir%/../web
    write_to:       %kernel.root_dir%/../web
    bundles:        [TerraKernelBundle, TerraGameBundle] # disable bundles parsing

    filters:
        cssrewrite: ~
        yui_js:  { jar: "%kernel.root_dir%/../bin/yuicompressor.jar" }
        yui_css: { jar: "%kernel.root_dir%/../bin/yuicompressor.jar" }

    assets: 
        bootstrap_min_css:
            inputs:
                - %kernel.root_dir%/../vendor/twbs/bootstrap/dist/css/bootstrap.min.css
            output: css/bootstrap.min.css
        jquery_min_js:
            inputs:
                - %kernel.root_dir%/../vendor/jquery/jquery/jquery-1.10.2.js
            output: js/jquery.min.js
        bootstrap_min_js:
            inputs:
                - %kernel.root_dir%/../vendor/twbs/bootstrap/dist/js/bootstrap.js
                - %kernel.root_dir%/../vendor/twbs/bootstrap/js/*.js
            output: js/bootstrap.min.js
        frontend_min_js:
            inputs:
                - %kernel.root_dir%/../vendor/jquery/jquery/jquery-1.10.2.js
                - %kernel.root_dir%/../vendor/twbs/bootstrap/dist/js/bootstrap.js
                - %kernel.root_dir%/../vendor/twbs/bootstrap/js/*.js
                - %kernel.root_dir%/../vendor/mopa/bootstrap-bundle/Mopa/Bundle/BootstrapBundle/Resources/public/js/mopabootstrap-collection.js
                - '@TerraGameBundle/Resources/public/js/frontend.js'
            output: js/frontend.min.js

D
Denis, 2015-07-16
@prototype_denis

Your application is running in the dev environment.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question