在Symfony 2.3.0-DEV(Windows)中配置Assetic、Sass和Compass

在Symfony 2.3.0-DEV(Windows)中配置Assetic、Sass和Compass,symfony,sass,compass-sass,assetic,symfony-2.3,Symfony,Sass,Compass Sass,Assetic,Symfony 2.3,我在C:\Ruby200-x64中安装了Ruby,路径设置为C:\Ruby200-x64\bin并运行: gem update --system gem install sass gem install compass 然后我在app/config/config.yml中配置了Assetic: ruby: C:\Ruby200-x64\bin\ruby.exe sass: C:\Ruby200-x64\bin\sass.bat filters:

我在
C:\Ruby200-x64
中安装了Ruby,路径设置为
C:\Ruby200-x64\bin
并运行:

gem update --system
gem install sass
gem install compass
然后我在
app/config/config.yml
中配置了Assetic:

ruby:           C:\Ruby200-x64\bin\ruby.exe
sass:           C:\Ruby200-x64\bin\sass.bat
filters:
    compass:
        bin: C:\Ruby200-x64\bin\compass.bat
app/Resources/views/base.html.twig
中,我添加了样式表块:

{% stylesheets
    'css/main.scss' filter="compass" %}
    <link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
我在用.bat结束路径时出错:

  [Assetic\Exception\FilterException]
  An error occurred while running:
  "C:\Ruby200-x64\bin\ruby.EXE" "C:\Ruby200-x64\bin\compass.bat" "compile" "C:\Users\Jes·s\AppData\Local\Temp" "--config" "C:\Users\Jes·s\AppData\Local\Temp\assC7D6.tmp" "--sass-dir" "" "--css-dir" "" "C:/Users/Jes·s/AppData/Local/Temp/assC7D7.tmp.scss"

  Error Output:
  C:/Ruby200-x64/bin/compass.bat:1: syntax error, unexpected tCONSTANT, expecting end-of-input
当不使用.bat扩展名时:

[Assetic\Exception\FilterException]
An error occurred while running:
"C:\Ruby200-x64\bin\ruby.exe" "C:\Ruby200-x64\bin\compass" "compile" "C:\Users\Jes·s\AppData\Local\Temp" "--config" "C:\Users\Jes·s\AppData\Local\Temp\ass52DB.tmp" "--sass-dir" "" "--css-dir" "" "C:/Users/Jes·s/AppData/Local/Temp/ass52DC.tmp.scss"

Error Output:
Configuration file, C:\Users\Jes·s\AppData\Local\Temp\ass52DB.tmp, not found or not readable.
我看到了这些(和其他):

  • 我尝试了很多东西,但我被困住了

没有.bat的版本是正确的,但是看起来是“Jes·s”文件夹名导致了问题(应该有带重音的u?。

您的config.yml应该是这样的

assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    bundles:        [ AJWPageBundle ]
#    compass.bin: W:\Ruby\1.9.2\bin\compass.bat
    java: /usr/bin/java
    ruby:           'W:\Ruby\bin\ruby.exe'
    sass:           'W:\Ruby\bin\sass.bat'
    filters:
        cssrewrite: ~
        sass:
          bin: %sass.bin%
          apply_to: "\.scss$"
        compass:
            bin: %compass.bin%
        closure:
            jar: "%kernel.root_dir%/Resources/java/compiler.jar"
        yui_css:
            jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
parameters:
     assetic.ruby.bin: 'W:\Ruby\bin\ruby'
     compass.bin: 'W:\Ruby\bin\compass'
     sass.bin:  'W:\Ruby\bin\sass'
确保修改路径以与文件系统匹配。 请注意,有些末尾有.exe或.bat,有些则没有

接下来在控制台中执行“php应用程序/控制台资产:安装” 这将在web/bundles中创建与src/bundles目录匹配的目录

在这里,您应该找到您将在下面的示例中调用的scss文件的路径:bundles/mybundle/css/bootstrap.scss

在你看来:

{% stylesheets
'bundles/mybundle/css/bootstrap.scss' output='css/*.css' filter="compass" %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{%样式表
'bundles/mybundle/css/bootstrap.scss'output='css/*.css'filter=“compass”%}
{%endstylesheets%}
最后在控制台中执行“php应用程序/控制台断言:转储”

这就是您在2014年2月1日这一特定时刻所要做的全部工作——我不需要修改ruby的任何批处理文件


您将发现assetic将找到文件web/bundles/mybundle/css/bootstrap.css以及您可能添加的任何其他css文件,将它们组合起来,然后将它们保存到web/css/nameoffile_123456.css中,并在末尾添加一些数字,以确保如果有更新,浏览器将被迫下载新版本。

Lol在我的用户名中添加符号肯定是愚蠢的(我认为W8将liveid配置文件中的名称作为用户名)。之前没有时间在用户名中没有符号的本地用户中测试它。我现在就去报告。您知道是否可以更改temp文件夹(../AppData/Local/temp/foo.tmp)?正确拼写您的名字绝对不愚蠢。需要ASCII用户名的软件缺陷应该报告给供应商(我建议您停止使用该供应商的产品,因为它们显然是白痴)
{% stylesheets
'bundles/mybundle/css/bootstrap.scss' output='css/*.css' filter="compass" %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}