Symfony Assetic Invalid Resource Type

I have a strange problem with symfony 2. I am working on a project that has all the stylesheets and javascript files loaded active (path / to / file), and I decided to use assetic with cssrewrite and yui_compressor, so I added them like this :

// this is just one file for example {% stylesheets 'bundles/mybundle/css/main.css' filter='?cssrewrite, ?yui_css' %} 

Now evething works fine in prod env, but the problem is in the dev environment. The file is linked correctly, I can open the file, but the resource type is actually text / html instead of text / css, even if the type is set to text / css as follows:

 <link rel="stylesheet" type="text/css" href="/app_dev.php/css/ab72c13_main_1.css"/> 

What could cause this strange problem?

+4
source share
3 answers

I finally found the problem with @cordoval.

I had two files that configured assetic: use_controller, and one of them redefined the other with true.

So the solution to this problem is to set assetic: use_controller: false and use assetic: dump --watch to automatically reset assetic if you don't want to do this every time you modify the css / js file.

+4
source

Try removing the yui_css filter and testing it separately.

0
source

Check security.yml and make sure css files are accessible for all roles

 access_control: - { path: ^/, role: IS_AUTHENTICATED_ANONYMOUSLY } 
0
source

All Articles