[英]Compass in Symfony 2 assetic Filter Exception
我已經在我的symfony 2項目中安裝了指南針。 現在我想將資產過濾器與指南針結合使用。 我正在使用Windows 7。
我認為它幾乎正常,但我仍然收到此錯誤:
[Assetic\Exception\FilterException]
An error occurred while running:
"C:\Ruby21-x64\bin\ruby.EXE" "C:\Ruby21-x64\bin\compass.BAT" "compile" "C:\
Users\tommie\AppData\Local\Temp" "--boring" "--config" "C:\Users\tommie\App
Data\Local\Temp\ass4325.tmp" "--sass-dir" "" "--css-dir" "" "C:/Users/tommi
e/AppData/Local/Temp/ass4326.tmp.scss"
Error Output:
C:/Ruby21-x64/bin/compass.BAT:1: syntax error, unexpected tCONSTANT, expect
ing end-of-input
我在html(twig)中的代碼:stylesheets.html.twig
{% stylesheets filter="compass" output='css/compiled/*.css'
"@AcmeSassDemoBundle/Resources/assets/css/base.scss"
%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
base.html.twig:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{% block title %}Sass Demo!{% endblock %}</title>
{#{% block stylesheets %}{% endblock %} #}
{% include "AcmeSassDemoBundle:Demo:stylesheets.html.twig" %}
<link rel="shortcut icon" href="{{ asset('favicon.ico') }}" />
</head>
<body>
<div id="header">
{% block header %}
<h1>Sass Demo</h1>
<div class="logo">this container is half as big as the sass.gif's dimension</div>
{% endblock %}
</div>
<div id="menu">
<ul>
<li class="add"><a href="#">add something</a></li>
<li class="edit"><a href="#">edit something</a></li>
<li class="delete"><a href="#">delete something</a></li>
</ul>
</div>
<div id="content">
{% block body %}hello sass!{% endblock %}
</div>
<div id="footer">
{% block footer %}awesome footer goes here ...{% endblock %}
</div>
{% block javascripts %}{% endblock %}</
</body>
index.html.twig:
{% extends 'AcmeSassDemoBundle:Demo:base.html.twig' %}
{% block body %}
<div class="content">
hello world
<div class="sub">
This text should be in green ...
<div class="sub">
... and this one in blue!
</div>
</div>
我的config.yml過濾器資產配置:
# Assetic Configuration
assetic:
debug: false
use_controller: true# default: true
filters:
sass: ~
compass:
compass:
bin: C:\Ruby21-x64\bin\compass.bat
base.scss
$main-background-color: #FFF;
$main-color: #FFF;
$light-color: #759E1A;
$link-color: #0088CC;
body {
background-color: #CCC;
}
@mixin rounded($side, $radius: 10px) {
border-radius: $radius;
border-#{$side}-radius: $radius;
-moz-border-radius-#{$side}: $radius;
-webkit-border-#{$side}-radius: $radius;
}
@import "header.scss";
@import "menu.scss";
@import "content.scss";
@import "footer.scss";
我不想勸阻你,但是使用Windows和Ruby這是更糟糕的組合,(節點也是,node_module有長樹子目錄,使得Windows有256個特權限制並且通過安裝軟件包會顯示錯誤)。 我的觀點就像是將您的項目移動到與您的服務器配置類似的虛擬機的替代方案。 (VirtualBox和Vagrant)
Linux對Ruby更友好(它支持他)並且有符號鏈接和長路徑名稱;
修修補補: https : //symfony.com/doc/2.8/setup/homestead.html
也許這個舊鏈接也會有所幫助: 如何在Windows下的Symfony2中使用SCSS過濾器?
這很可能是你已經嘗試/注意到的,但以防萬一:
錯誤看起來更像是紅寶石翻譯正在死亡,而不是在你的scss / twig上窒息。 由於ruby不希望使用.BAT腳本,因此這有一定程度的意義。
通常只使用'指南針',而不是'compass.BAT',它通常只用'指南針'調用紅寶石。
即
“C:\\ Ruby21-x64 \\ bin \\ ruby.EXE”“C:\\ Ruby21-x64 \\ bin \\ compass.BAT”“compile”“C:\\ Users \\ tommie \\ AppData \\ Local \\ Temp”“ - boring” “--config”“C:\\ Users \\ tommie \\ App Data \\ Local \\ Temp \\ ass4325.tmp”“ - sass-dir”“”“ - css-dir”“”“C:/ Users / tommi e /AppData/Local/Temp/ass4326.tmp.scss”
通常會
“C:\\ Ruby21-x64 \\ bin \\ ruby.EXE”“C:\\ Ruby21-x64 \\ bin \\ compass”“compile”“C:\\ Users \\ tommie \\ AppData \\ Local \\ Temp”“ - boring”“ - -config“”C:\\ Users \\ tommie \\ App Data \\ Local \\ Temp \\ ass4325.tmp“” - sass-dir“”“” - css-dir“”“”C:/ Users / tommi e / AppData /Local/Temp/ass4326.tmp.scss”
基本上,將compass.bin路徑設置為不包含.bat,你可能會沒事的。 這通常位於config.yml中的assetic.filters.compass.bin中
另見https://github.com/symfony/AsseticBundle/issues/158
這也揭示了特殊角色不是很受歡迎,不確定它在dirnames中的空間有多好。 如果沒有.bat它仍然不起作用,那些也可能導致窒息
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.