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:
. I’ve put the
version of the stylesheet in
. When I make changes to the scss file, I compile it locally by entering into my browser:
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
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
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.
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);