Created
May 6, 2012 11:29
-
-
Save mishak87/2621764 to your computer and use it in GitHub Desktop.
Builds css from sass and css files - using Nette conventions for directory structure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$documentRootStyles = realpath(__DIR__ . '/../document_root/css'); | |
$appDir = realpath(__DIR__ . '/../app'); | |
foreach (new DirectoryIterator($appDir) as $file) { | |
if (!$file->isDir() || !preg_match('/.+Module/', $file->getFilename())) { | |
continue; | |
} | |
$module = lcfirst(substr($file->getFilename(), 0, -6)); | |
$stylesDir = $appDir . '/' . $file->getFilename() . '/styles'; | |
if (is_dir($stylesDir)) { | |
foreach (new DirectoryIterator($stylesDir) as $file) { | |
if (!$file->isFile()) { | |
continue; | |
} | |
$source = $file->getPathname(); | |
$ext = pathinfo($source, PATHINFO_EXTENSION); | |
$target = $documentRootStyles . '/' . $module . '/' . substr(basename($source), 0, -strlen($ext) - 1) . '.css'; | |
@mkdir(dirname($target)); | |
if ($ext == 'sass' || $ext == 'scss') { | |
shell_exec($command = 'sass --no-cache --style expanded "' . $source . '" "' . $target . '"'); | |
} elseif ($ext == 'css') { | |
copy($source, $target); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment