What is the workflow for using scssphp?

I’m trying to migrate my css over to scss for a PHP application, but I’m confused about the proper workflow for generating css files. I’m using scssphp
, which is a compiler for scss written in PHP.

In all my pages, I use the following stylesheet: css/mycss.css
. I’ve put the scss
version of the stylesheet in css/scss/mycss.scss
. When I make changes to the scss file, I compile it locally by entering into my browser:

localhost/mywebsite/style.php/mycss.scss

The style.php
file is as follows:

require "vendor/leafo/scssphp/scss.inc.php";
$scss = new scssc();
$directory = "css/scss";
$server = new scss_server($directory,null,$scss);
$server->serve();

This compiles the scss file and writes it to the css/scss/scss_cache
folder. The filename is some hash. Here is my resulting directory structure:

style.php
-css
 mycss.css
    -scss
     mycss.scss
        -scss_cache
         4edf7f7bf9238jdsk9281sjkj32.css

Now ideally, I would like for the compiler to overwrite the css/mycss.css
file. Is there a way to do this, or what’s a proper workflow for replacing the original css file with the newly compiled css? I could always just copy and paste every time, but that doesn’t seem very efficient.

scssphp
is meant to be used to serve the stylesheets directly. But if you’d like to just use the compiler functionality, you can do that:

require "vendor/leafo/scssphp/scss.inc.php";
$scss = new scssc();

$scssIn = file_get_contents(__DIR__ . '/css/scss/mycss.scss');
$cssOut = $scss->compile($scssIn);
file_put_contents(__DIR__ . '/css/mycss.css', $cssOut);

See http://leafo.net/scssphp/
.

Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 前端开发 » What is the workflow for using scssphp?

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录