【问题标题】:Is there any way to use Compass with PHPSass compiler?有没有办法将 Compass 与 PHPSass 编译器一起使用?
【发布时间】:2013-03-02 12:52:18
【问题描述】:

我们的样式表是在 SCSS 中使用 Compass mixin 构建的。对于开发,我们使用 CodeKit,因为它是一个很棒的工具,我真的很喜欢它。但是现在我们需要在服务器端实现自动编译的工具。我们使用了 PHPSass (phpsass.com),因为它非常支持纯 SASS。不幸的是,我不知道如何将 Compass 附加到其中。它还没有内置支持,并且 Compass 仅作为 gem 包提供 - 无法下载它并将其 mixins 放入项目文件夹中。有人遇到过此类问题吗?

【问题讨论】:

  • 您是否有理由不只是通过命令行使用 Sass/Compass?它通过 watch 自动编译,或者您可以将其作为 cron 运行。如果您真的需要使用 PHP,您甚至可以通过 exec() 调用它。
  • 客户端希望能够从 CMS 动态更改模板(如重新定义颜色等),所以我真的需要在服务器端编译模板。 exec() 不是一个解决方案——它只能在定制的专用服务器上工作,我们希望创建简单且可重用的代码。这就是为什么 PHPSass 看起来很优秀的原因。
  • 如果你只需要 mixins,你可以在这里获取它们:github.com/chriseppstein/compass/tree/stable/frameworks/compass/…。但是,您不会拥有像 sprite 生成器这样有价值的辅助函数,因为它们都是用 Ruby 编写的。

标签: php sass compass-sass


【解决方案1】:

众所周知,截至 2013 年 2 月 11 日,phpSASS 支持扩展。来自开发者推特的帖子,“我们现在支持扩展,这意味着 Compass。非常感谢 Juan Manuel Vergés Solanas 和 tsi 的贡献!” http://www.phpsass.com/https://twitter.com/PHPSass

【讨论】:

    【解决方案2】:

    https://github.com/chriseppstein/compass/tree/stable/frameworks/compass/stylesheets 获取mixins(我想我实际上是从一些windows/ruby 的东西下载了指南针) 注意,并非所有的指南针都可以与phpsass 一起使用。我目前使用一个非常小的子集,我认为边界半径和框模型。似乎有些 sass 函数没有移植到 php 有问题。

    $loadpath = array(pathtosassfiles, pathtocompass);
        $defaultOptions = array(
        'load_paths'     =>   $loadpath  ,
        'cache'          => false,
        'syntax'         => 'scss',
        'extensions'     =>  array('compass'=>array())
        );
    $debugoptions = array(
        'line_numbers'   => false,
         'debug_info'    => true,
        'style'          => 'nested', //'compressed' 'compact' 'expanded' 'nested'
        );
    $minoptions = array(
        'line_numbers'   => false,
        'debug_info'     => false,
        'style'          => 'compressed', //'compressed' 'compact' 'expanded' 'nested'
        );
    //then when you instantiate:
    $sass = new SassParser(array_merge($defaultOptions, $minoptions));
    

    【讨论】:

      猜你喜欢
      • 2018-03-15
      • 2016-11-01
      • 1970-01-01
      • 2018-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多