How to go about pre generating css file with variables from theme options

$ss_dir = get_stylesheet_directory(); // Shorten code, save 1 call
ob_start(); // Capture all output (output buffering)
require($ss_dir . '/library/css/dynamic.css.php'); // Generate CSS
$css = ob_get_clean(); // Get generated CSS (output buffering)
file_put_contents($ss_dir . '/library/css/static.css', $css, LOCK_EX); // Save it

Regards.

PS: You cannot be a developer with scratchy files’ skills. They’re not optional.