Fontawesome fonts fail after assets:install and assetic:dump

前端 未结 5 535
醉话见心
醉话见心 2021-01-06 11:05

I\'m trying to setting up a site I\'m working on at shared hosting and all works fine but FontAwesome icons since Symfony does not find them where they should be. I follow t

5条回答
  •  误落风尘
    2021-01-06 11:36

    I've been dealing with this for a while and came up with a new solution. Improving @lenybernard's answer a little bit, here is my solution:

    Since the @import is not located in the font-awesome-min.css file, it didn't work for my case. I was using a theme and found out that the style sheet related to the theme had the import annotation. Also, the theme was requiring Bootstrap to be loaded before its own CSS file, so moving the theme.css file to top of the list, or separating it as mentioned in the previous answer broke the theme completely. So, an ultimate solution for this is to find the line with the @import tag and put it in the first line of the first file in your assetic list, and remove it from the file it is referred. For example:

    'bundles/foo/bootstrap.css'
    'bundles/foo/custom_theme.css' <- if your @import is here
    'bundles/foo/font-awesome.css'
    

    ...

    'bundles/foo/bootstrap.css' <- put it here
    'bundles/foo/custom_theme.css' <- and remove it from this one
    'bundles/foo/font-awesome.css'
    

    Another solution is to create a new CSS file and name it however you want, put your @import line on this file, and put this file on top of the list. For example:

    'bundles/foo/font-awesome-fix.css' <- put @import here
    'bundles/foo/bootstrap.css'
    'bundles/foo/custom_theme.css' <- and remove it from this one
    'bundles/foo/font-awesome.css'
    

提交回复
热议问题