如何让 Assetic 在 Windows 上的 Zend Framework 上编译 SCSS? [英] How can I get Assetic to compile SCSS on Zend Framework on Windows?

查看:37
本文介绍了如何让 Assetic 在 Windows 上的 Zend Framework 上编译 SCSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站在 Zend Framework 上,并使用 Assetic 编译 SCSS 并将其缩小.

My site is on Zend Framework and uses Assetic to compile SCSS and minify it.

当我在 Ubuntu 上开发时,它运行得非常好.

It works wonderfully when I'm developing on Ubuntu.

有时我需要在 Windows (WAMP) 而非 Ubuntu 上进行开发.

Sometimes I need to develop on Windows (WAMP) instead of Ubuntu.

我一直无法让 Assetic 在 Windows 上工作.

I haven't been able to get Assetic to work on Windows.

我发现了很多关于它的问答,但似乎没有任何答案适用于我.例如.我认为我在任何地方都没有 config.yml 文件.

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.

如何让 Assetic + sass 与 Symfony2 一起工作在 Windows 中?

如何在Windows下的Symfony2中使用SCSS过滤器?

这里有一个错误:Assetic\Exception\FilterException: 运行时出错:"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" 错误输出:文件名、目录名或卷标语法不正确.

想法?

推荐答案

我想我已经成功了,但我不能 100% 确定我可以重现修复它的步骤.

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.

我在 C:\Ruby193\ 安装了 Ruby.我需要将其bin"文件夹中的 sass.bat 文件编辑为:

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" %*

我阅读了 https://github.com/symfony/AsseticBundle/issues/81.

我将 C:\wamp\bin\php\php5.3.10\PEAR\pear\Symfony\Component\Process\Process.php 中的文件替换为 https://raw.github.com/symfony/Process/master/Process.php.

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.

我不知道这是否重要,但 Assetic 使用了正斜杠而不是名为 DIRECTORY_SEPARATOR 的 PHP 常量,所以:

I don't know whether this matters, but Assetic was using forward slashes instead of the PHP constant called DIRECTORY_SEPARATOR, so:

在 Assetic\Filter\Sass\SassFilter.php 中,我添加了$root = str_replace('/', DIRECTORY_SEPARATOR, $root);//Windows 修复$root = $asset->getSourceRoot();

In Assetic\Filter\Sass\SassFilter.php, I added $root = str_replace('/', DIRECTORY_SEPARATOR, $root);//fix for Windows after $root = $asset->getSourceRoot();

稍微低于它,我将一行更改为 $pb->add('--load-path')->add(dirname($root.DIRECTORY_SEPARATOR.$path));.

And slightly below that, I changed a line to $pb->add('--load-path')->add(dirname($root.DIRECTORY_SEPARATOR.$path));.

这篇关于如何让 Assetic 在 Windows 上的 Zend Framework 上编译 SCSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆