How can I get Assetic to compile SCSS on Zend Framework on Windows?

巧了我就是萌 提交于 2019-12-19 12:04:01

问题


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

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