用scssphp更改scss变量

我正在使用scssPHP来查看是否可以使用它来更改在现有的scss中设置的变量,因此我设置了一个测试用例:

require_once "scssPHP-0.1.7/scss.inc.PHP";

use Leafo\ScssPHP\Compiler;
use Leafo\ScssPHP\Server;

$scss = new Compiler();
$scss->addImportPath('testsass');

$scss->compile('$color: blue;');
$test = $scss->compile('@import "test.scss"');

echo $test;

我的test.scss看起来像:

$color: red;

body {
    background: $color;
}

现在我希望我可以在$PHP中将$color更改为blue,然后进行编译,并且我确定上面显示的方式不正确.

但是,有一种方法可以将$color的变量更改为blue,而不是重新编译test.scss?

解决方法:

我自己用完美无缺的解决方法来回答这个问题.
我用所有变量创建了一个config.scss.并决定在编译导入config.scss的layout.scss之前打开并重写它

require_once "scssPHP-0.1.7/scss.inc.PHP";

use Leafo\ScssPHP\Compiler;
use Leafo\ScssPHP\Server;

$scss = new Compiler();
$scss->setImportPaths('sass');

//$txt = '$color: yellow;';
$txt = '$font: "Open sans";';
$txt .= '$body-font-size: 15px;';
$txt .= '$containerWidth: 1140px;';
$txt .= '$gutter-size: 15px;';
$txt .= '$primarycolor: red;';
$txt .= '$secondarycolor: blue;';
$txt .= '$background: #e8e3e3;';
$txt .= '$textcolor: $primarycolor;';
$txt .= '$linkcolor: #000;';

$file = fopen('sass/_configuratie.scss', "w");
if (fwrite($file, $txt)) {
    $server = new Server('sass', null, $scss);
    $server->serve();
} 

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...