$rootDir = dirname(__FILE__) . '/../..';
$files = array(
- array(
- 'less' => array(
- 'directory' => "{$rootDir}/roojs1/less/bootstrap",
- 'name' => 'bootstrap'
- ),
- 'css' => array(
- 'directory' => "{$rootDir}/roojs1/css-bootstrap/",
- 'name' => 'bootstrap'
- )
+ "{$rootDir}/roojs1/less/bootstrap/bootstrap.less" => array(
+ 'baseDir' => "{$rootDir}/roojs1/css-bootstrap",
+ 'name' => 'bootstrap.css',
+ 'minify' => 'bootstrap.min.css'
),
- array(
- 'less' => array(
- 'directory' => "{$rootDir}/roojs1/less/roojs-bootstrap",
- 'name' => 'roojs-bootstrap'
- ),
- 'css' => array(
- 'directory' => "{$rootDir}/roojs1/css-bootstrap/",
- 'name' => 'roojs-bootstrap'
- )
+ "{$rootDir}/roojs1/less/roojs-bootstrap/roojs-bootstrap.less" => array(
+ 'baseDir' => "{$rootDir}/roojs1/css-bootstrap",
+ 'name' => 'roojs-bootstrap-debug.css',
+ 'minify' => 'roojs-bootstrap.css'
)
);
-print_R($files);exit;
-
require_once 'HTML/Less.php';
$less = new HTML_Less();
-require_once 'HTML/CSS/Minify.php';
-
-$minify = new HTML_CSS_Minify();
+foreach ($files as $src => $file){
-foreach ($files as $less => $file){
-
- if(!file_exists($less)){
+ if(!file_exists($src)){
echo "{$less} does not exist...\n";
continue;
}
- print_R($file);
- exit;
try {
- $css = "{$file['directory']}{$file['name']}.css";
+ $css = "{$file['baseDir']}/{$file['name']}";
- echo "Compiling - {$less} To {$css}\n";
+ echo "Compiling - {$src} To {$css}\n";
- $less->compileFile($less, $css);
+ $less->compileFile($src, $css);
- if(!file_exists($css)){
- echo "Compile failed?!\n";
- continue;
- }
+ } catch (Exception $ex) {
+ echo "lessphp fatal error: {$ex->getMessage()}\n";
+ }
+
+}
+
+require_once 'HTML/CSS/Minify.php';
+
+foreach ($files as $src => $file){
+
+ $css = "{$file['baseDir']}/{$file['name']}";
+
+ if(!file_exists($css)){
+ echo "{$css} does not exist...\n";
+ continue;
+ }
+
+ try {
+ $min = "{$file['baseDir']}/{$file['minify']}";
+ echo "Minifing - {$css} To {$min}\n";
+ $minify = new HTML_CSS_Minify($file['baseDir'], $file['baseDir'], array($file['name']));
+
+ $content = $minify->minify();
+ file_put_contents($min, $content);
+
} catch (Exception $ex) {
- echo "lessphp fatal error: {$ex->getMessage()}\n";
+ echo "Minify fatal error: {$ex->getMessage()}\n";
}
-
-}
\ No newline at end of file
+}