Search code examples
phpcsssymfonyassetic

Symfony 3 - Assetic dump works on dev but doesn't work on prod


I'm new with symfony 3 and I'm trying to develop a web app application. To combine my css and js files, I've installed assetic bundle and I'm using it on dev mode, It works fine and I haven’t any problems.

Then when I try to test my web app on production mode, css and js are not complete and the website doesn't work fine.

I’ve tried these two commands but nothing has changed:

  • php bin/console assetic:dump -env=prod
  • php bin/console cache:clear --no-warmup -e prod

The only way to make production work is to set $kernel = new AppKernel('prod', true); on app.php file, but I don't think this is the best solution.

Any ideas?

Here my code on base template:

{% block stylesheets %}
        {% stylesheets
        'css/dist/bootstrap.css'
        'css/dist/bootstrap-grid.css'
        'css/dist/bootstrap-reboot.css'
        'css/dist/font-awesome.css'
        'css/dist/sidenav.css'
        'css/dist/head.css'
        'css/dist/main.css'
        filter='cssrewrite' output='css/compiled/app.css' %}
        <link rel="stylesheet" href="{{ asset_url }}">
        {% endstylesheets %}
    {% endblock %}

As you can see I get my css files from <root>/web/css/dist/* and I dump on <root>/web/css/compiled/app.css the file is created on dump, But not all css are there.

Same procedure for js files.


Solution

  • You need to install your assets too :

    php bin/console assets:install --env=prod