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 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题