问题
My site is on Zend Framework and uses Assetic to compile SCSS and minify it.
It works wonderfully when I'm developing on Ubuntu.
Sometimes I need to develop on Windows (WAMP) instead of Ubuntu.
I haven't been able to get Assetic to work on Windows.
I've found many Q&As about it but no answers seem to apply to me. E.g. I don't think I have a config.yml file anywhere.
How to have Assetic + sass work with Symfony2 in Windows?
How to use SCSS filter in Symfony2 under Windows?
Here is an error:
Assetic\Exception\FilterException: An error occurred while running: "C:\Ruby193\bin\sass.bat" "--load-path" "C:\code\branches\signup-and-login\scss" "--scss" "--cache-location" "C:\Windows\Temp" "C:\Windows\Temp\assCCF2.tmp" Error Output: The filename, directory name, or volume label syntax is incorrect.
Thoughts?
回答1:
I think I got it working, but I'm not 100% sure I could reproduce the steps to fix it.
So please add a new answer if you figure out better details.
I have Ruby installed at C:\Ruby193\
. I needed to edit the sass.bat file in its 'bin' folder to be:
@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"ruby.exe" "C:/Ruby193/bin/sass" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
@"C:/Ruby193/bin/ruby.exe" "%~dpn0" %*
I read https://github.com/symfony/AsseticBundle/issues/81.
I replaced the file at C:\wamp\bin\php\php5.3.10\PEAR\pear\Symfony\Component\Process\Process.php with https://raw.github.com/symfony/Process/master/Process.php.
I don't know whether this matters, but Assetic was using forward slashes instead of the PHP constant called DIRECTORY_SEPARATOR, so:
In Assetic\Filter\Sass\SassFilter.php, I added
$root = str_replace('/', DIRECTORY_SEPARATOR, $root);//fix for Windows
after
$root = $asset->getSourceRoot();
And slightly below that, I changed a line to $pb->add('--load-path')->add(dirname($root.DIRECTORY_SEPARATOR.$path));
.
来源:https://stackoverflow.com/questions/11054715/how-can-i-get-assetic-to-compile-scss-on-zend-framework-on-windows