0
votes

I'm using Assetic to manage assets in my Symfony2 project. It worked well before i made my application accessible with a domain folder.

before : myapplication.local    // Assetic works

now    : mydomain.local/myapplication    // Assetic doesn't work

The requested css files are called but the filter cssrewrite writes a wrong path for the ressources.

Error : NetworkError: 404 Not Found - http://www.mydomain.local/Resources/public/images/menu/nav-bg-1.png

The expected URL should looks like http://www.mydomain.local/myapplication/Resources/public/images/menu/nav-bg-1.png

Here is my Assetic Call

{% block stylesheets %}
     {% stylesheets
         '@Mybundle/Resources/public/css/myfile.css' filter='cssrewrite' %}
          <link rel="stylesheet" href="{{ asset_url }}" />
     {% endstylesheets %}
{% endblock %}

I know Assetic say to not use the @-naming when using cssrewrite. But it worked fine without the domain folder, and using "bundles/mybundle/css/myfile.css" does not solve the problem.

If you need anymore information, just ask me ;).

Thank you for your time and you help.

3
have you called cache:clear and assets:install? - Joshua
Yes, both of them but nothing changed - Benjamin Fernandes
even if you reverted to the required notation which doesn't use the @? Which exact version do you use? - Joshua
The path is still the same when i don't use @ - naming. I'm using assetic 2.3 with symfony 2.6 - Benjamin Fernandes

3 Answers

1
votes

You should use naming without @ as said in the documentation. Also you need to dump your assets via assetic every time you change anything with them.

To dump assetic run next command:

php app/console assetic:dump

or

php app/console assetic:dump --env=prod // To generate only files needed for production environment
0
votes

I managed to fixe this issue by removing the cssrewrite filter and putting all my images, fonts, etc... in web/images or web/fonts, etc... Then in my css, all my path are like "../folder/file"

0
votes

You can define the assets base URL in your app/config/config*.yml files:

In dev environment: app/config/config_dev.yml

framework:
    templating:
        engines: ['twig']
        assets_base_urls:
            http: [http://www.mydomain.local/myapplication/]

In prod environment: app/config/config_prod.yml

framework:
    templating:
        engines: ['twig']
        assets_base_urls:
            http: [http://www.example.com/static/]

The cssrewrite filter should remove Resources/public/ from the URL.