buildSDK/less-bootstrap-compiler.php
[roojs1] / buildSDK / less-bootstrap-compiler.php
index 7a8dee0..f5189e4 100644 (file)
@@ -13,16 +13,19 @@ ini_set('include_path',
     ini_get('include_path')
 );
 
-$rootDir = dirname(__FILE__) . '/../../';
+$rootDir = dirname(__FILE__) . '/../..';
 
 $files = array(
-    "roojs1/less/bootstrap/bootstrap.less" => array(
-        "roojs1/css-bootstrap/bootstrap.css",
-        "roojs1/css-bootstrap/bootstrap.min.css"
+    "{$rootDir}/roojs1/less/bootstrap/bootstrap.less" => array(
+        'baseDir' => "{$rootDir}/roojs1/css-bootstrap",
+        'name' => 'bootstrap.css',
+        'minify' => 'bootstrap.min.css',
+        'variables' => "@import 'variables.less';"
     ),
-    "roojs1/less/roojs-bootstrap/roojs-bootstrap.less" => array(
-        "roojs1/css-bootstrap/roojs-bootstrap-debug.css",
-        "roojs1/css-bootstrap/roojs-bootstrap.css"
+    "{$rootDir}/roojs1/less/roojs-bootstrap/roojs-bootstrap.less" => array(
+        'baseDir' => "{$rootDir}/roojs1/css-bootstrap",
+        'name' => 'roojs-bootstrap-debug.css',
+        'minify' => 'roojs-bootstrap.css'
     )
 );
 
@@ -33,22 +36,49 @@ $less = new HTML_Less();
 foreach ($files as $src => $file){
 
     if(!file_exists($src)){
-        echo "{$src} does not exist...\n";
+        echo "{$less} does not exist...\n";
         continue;
     }
+
+    try {
+        
+        $css = "{$file['baseDir']}/{$file['name']}";
+        
+        echo "Compiling - {$src} To {$css}\n";
+        
+        $less->compileFile($src, $css);
+        
+    } 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']}";
     
-    echo "{$src} exist \n";
-
-//    try {
-//
-//        foreach ($file as $f){
-//            echo "Compiling - {$src} To {$f}\n";
-//
-//            $less->compileFile($src, $f);
-//        }
-//
-//    } catch (Exception $ex) {
-//        echo "lessphp fatal error: {$ex->getMessage()}\n";
-//    }
-
-}
\ No newline at end of file
+    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['baseDir']);
+
+        file_put_contents($min, $content);
+        
+    } catch (Exception $ex) {
+        echo "Minify fatal error: {$ex->getMessage()}\n";
+    }
+    
+}