500 error when compiling scss in symfony2

孤者浪人 提交于 2020-01-02 17:54:10

问题


I am getting a 500 error when compiling scss files with assetic. Strangely enough, using php app/console assetic:dump the scss compiles without issue. Resources in web/bundles are relative symlinks.

I'm running OSX 10.8, symfony 2.3, and php 5.4.20.

config.yml

# Assetic Configuration
assetic:
    debug:          %kernel.debug%
    use_controller: false
    bundles:        [ ]
    filters:
        cssrewrite: ~
        sass:
          apply_to: "\.scss$"

base.html.twig

{# ... #}
{% stylesheets
    filter='cssrewrite'
    'bundles/acmehello/css/main.css'
    'bundles/acmehello/scss/page.scss'
%}
    <link rel="stylesheet" href="{{ asset_url }}"/>
{% endstylesheets %}
{# ... #}

回答1:


The issue was the fact that I am using rvm, which causes issues with sass paths (thanks to this SO answer).

To solve this, I generated an rvm gemset with:

# will create 'php_sass' and 'php_compass' executables in $GEM_HOME
rvm wrapper ruby-1.9.3-p194 php sass compass

And added the following to my config.yml file:

assetic:
    debug:          %kernel.debug%
    use_controller: true
    bundles:        [ ]
    filters:
        cssrewrite: ~
        scss:
          sass: /Users/Nick/.rvm/bin/php_sass
          apply_to: "\.scss$"

SCSS files now compile just fine. Compass users will need to point assetic to the gemset for compass



来源:https://stackoverflow.com/questions/19411311/500-error-when-compiling-scss-in-symfony2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!