duanli12176 2013-12-27 02:07
浏览 44

如何使用这两个库将scss文件(使用指南针mixins / features)编译成php中的css?

I have a lot of scss files that are neatly organised into folders and linked to each other via @import and I need to compile them into css on the server side in php on the fly. One of the files [application.scss] links to all the files which then link to all the other scss files via lots of @import. So I just need to pass application.scss to these two libraries and they should do the rest.

I have been using this https://github.com/leafo/scssphp PHPSCSS and it was working perfectly fine until I started coming across errors "undefined mixin X/Y/Z", but then I realised that scss files I am using have been written using compass which then led me into using this https://github.com/leafo/scssphp-compass PHPSCSS-COMPASS with this piece of code/example working perfectly fine:

require "compass.inc.php";
require "scss.inc.php";
$scss = new scssc();
new scss_compass($scss);

echo $scss->compile('
        @import "compass";

        .shadow {

         @include box-shadow(10px 10px 8px red);

       }
');

The problem is, its not practical nor feasible for me to pass all scss code as a string in the place of .shadow {@include box-shadow( 10px 10px 8px red); } I need to pass in application.scss file not scss code snippet. I tried doing this but it didnt work:

require "compass.inc.php";
require "scss.inc.php";
$scss = new scssc();
new scss_compass($scss);

echo $scss->compile('
        @import "compass";

        "application.scss"
');

This did not work either:

$scss = new scssc();
new scss_compass($scss);
$server = new scss_server("sass",null,$scss);
$server->serve();

Nor did this:

$scss = new scssc();
new scss_compass($scss);
$scss->setImportPaths("sass/");
echo $scss->compile('@import "compass"');
echo $scss->compile('@import "application.scss"');

Could anyone help ?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 这种微信登录授权 谁可以做啊
    • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
    • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
    • ¥15 网络设备配置与管理这个该怎么弄
    • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
    • ¥20 西门子S7-Graph,S7-300,梯形图
    • ¥50 用易语言http 访问不了网页
    • ¥50 safari浏览器fetch提交数据后数据丢失问题
    • ¥15 matlab不知道怎么改,求解答!!
    • ¥15 永磁直线电机的电流环pi调不出来