0
votes

As said in the title my js / css / images in assetic doesn't generate in prod

i've put them all in the base.html.twig like this

    {% block stylesheets %}
        {% stylesheets
            '@BlubirdCrmBundle/Resources/public/css/bootstrap.min.css'
            '@BlubirdCrmBundle/Resources/public/css/bootstrap-theme.min.css'
            '@BlubirdCrmBundle/Resources/public/css/bbgrid.css'
            ....
            output='css/compiled/all.css' %}
            <link rel="stylesheet" href="{{ asset_url }}" />
        {% endstylesheets %}
    {% endblock %}

    {% javascripts
        '@BlubirdCrmBundle/Resources/public/js/jquery-2.1.3.min.js'
        '@BlubirdCrmBundle/Resources/public/js/bootstrap.min.js'
        ....
        output='js/compiled/all.js' %}
        <script src="{{ asset_url }}"></script>
    {% endjavascripts %}

and my images :

{% image '@BlubirdCrmBundle/Resources/public/images/loadingSpinner.gif' %}<img id="spinner" src="{{ asset_url }}"/>{% endimage %}

everything works fine in dev

ut in prod it doesn't generate the new js and images that i've added over the time.

In my app my kernel is generated like this :

$kernel = new AppKernel('prod', false);

And before anyone tells me to

./console cache:clear --env=prod --no-debug
./console assetic:dump --env=prod --no-debug

I can't access console with my ovh server so i have to manually connect on server and delete the files in cache

i tried to delete the old compiled files in the /web file but nothing is generated ...

any idea on how to do it without console ?

Thank you !

1

1 Answers

2
votes

You will need to find a way to execute this:

./console assetic:dump --env=prod --no-debug

In dev mode, assetic links to assets through a controller. Controller finds the right asset, builds it if necessary and delivers to the browser. That is why it works in dev mode.

In prod mode this approach would be too slow, so assetic needs to generate the files upfront, so they can be served statically. That is why you need to find a way to execute that command.

If there is no way to run console commands on the server, there is a possibility to generate production assets on a dev server, add the files to source control and then deploy them with the rest of the code.

A little bit off topic, but assetic is in general being replaced in favor of more popular and framework independent front end tools such as gulp. Assetic is no longer bundled with symfony 3 by default. Even though a few months back it was described as "best practice" in symfony docs.