A ready to go server side scss builder. Based on the last time of filechange of your scss files, the script uses awesome scssphp to build your css code.
More or less its just a wrapper for scssphp.
Use composer to install the script:
composer require basteyy/scss-php-builder
<?php
// Get composers autoloader
require __DIR__ . '/vendor/autoload.php';
// Construct the class
$scss = new \basteyy\ScssPhpBuilder\ScssPhpBuilder();
// Add the input folder
$scss->addFolder(__DIR__.'/scss');
// Define the output file
$scss->addOutputeFile(__DIR__ . '/css/style.css');
// Define the scss starting point
$scss->addStartingFile(__DIR__ . '/scss/style.scss');
// Than compile the scss source
$scss->compileToOutputfile();
Instead of expand the compiled css, you should use SourceMaps. Anyway, for expand the compiled:
$scss->setOutputExpanded();
<?php
// Get composers autoloader
require __DIR__ . '/vendor/autoload.php';
// Construct the class
$scss = new \basteyy\ScssPhpBuilder\ScssPhpBuilder();
// Add the input folder
$scss->addFolder(__DIR__.'/scss');
// Define the output file
$scss->addOutputeFile(__DIR__ . '/css/style.css');
// Define the scss starting point
$scss->addStartingFile(__DIR__ . '/scss/style.scss');
// If you like, you can acticate sourcemap by setup the remote url
$scss->setSourcemapFolderUrl('/css/');
// Than compile the scss source
$scss->compileToOutputfile();
Keep in mind, that you can the option, which is passed to the __construct will overwrite/control the sourcemap settings (see __construct Options)
$scss->compileToOutputfile(true);
$scss->getCompiledCode();
$scss->getCompiledCode(true);
You can pass a few options to the __construct:
// Construct the class
$scss = new \basteyy\ScssPhpBuilder\ScssPhpBuilder([
'auto_create_folders' => true,
'auto_create_files' => true,
'write_source_map' => true
]);
auto_create_folders if true, will create all folders auto_create_files if true, will create all foles write_source_map if true, will create the source map
The MIT License (MIT). Please see License File for more information.