5 $cc = explode('/', $cwd);
6 if (array_pop($cc) !== 'roojs1') {
7 echo "this should be run in roojs1 directory...\n";
11 ini_set('include_path',
12 dirname(__FILE__) . '/../:' .
13 dirname(__FILE__) . '/../../pear:' .
14 ini_get('include_path')
17 $rootDir = dirname(__FILE__) . '/../..';
20 "bootstrap.scss" => array(
21 "scssDir" => "{$rootDir}/roojs1/scss/bootstrap",
22 'baseDir' => "{$rootDir}/roojs1/css-bootstrap4",
23 'name' => 'bootstrap.css',
24 'minify' => 'bootstrap.min.css',
25 'sourceMapRootpath' => '../scss/bootstrap/',
26 'variables' => "@import 'functions';\n@import 'variables';"
29 "roojs-bootstrap.scss" => array(
30 "scssDir" => "{$rootDir}/roojs1/scss/roojs-bootstrap",
31 'baseDir' => "{$rootDir}/roojs1/css-bootstrap4",
32 'name' => 'roojs-bootstrap-debug.css',
33 'minify' => 'roojs-bootstrap.css',
34 'sourceMapRootpath' => '../scss/roojs-bootstrap/',
35 'variables' => "@import '../bootstrap/functions';\n@import '../bootstrap/variables';"
39 require_once 'System.php';
40 $sassc = System::which("sassc");
44 foreach($files as $file => $f) {
46 $tmpFile = tempnam("/tmp/", "scss");
47 file_put_contents($tmpFile, "{$f['variables']}\n@import \"{$file}\";\n");
48 echo file_get_contents($tmpFile);
52 $cmd = "{$sassc} --sourcemap=auto -I {$f['scssDir']} $tmpFile {$f['baseDir']}/{$f['name']}";
55 $cmd = "{$sassc} --style=compressed --sourcemap=auto -I {$f['scssDir']} $tmpFile {$f['baseDir']}/{$f['minify']}";
64 foreach ($files as $src => $file){
66 $css = "{$file['baseDir']}/{$file['name']}";
68 if(!file_exists($css)){
72 $dir = "{$file['baseDir']}/{$file['sourceMapRootpath']}";
74 $variable = "{$dir}variables.less";
76 if(file_exists($variable) && filemtime("{$dir}variables.less") > filemtime($css)){
82 foreach(scandir($dir) as $f) {
84 if (!strlen($f) || $f[0] == '.') {
90 if(filemtime($less) > filemtime($css)){
97 echo "{$css} already up-to-date \n";
103 require_once 'HTML/Scss.php';
105 foreach ($files as $src => $file){
107 if(!file_exists($file['scssDir'].'/'. $src)){
108 echo "{$file['scssDir']}/{$src} does not exist...\n";
114 $scss = new HTML_Scss();
116 $scss->setSourceMap(HTML_Scss::SOURCE_MAP_FILE);
117 $scss->setSourceMapOptions(array(
118 'sourceRoot' => $file['sourceMapRootpath'],
120 // an optional name of the generated code that this source map is associated with.
121 'sourceMapFilename' => "{$file['baseDir']}/{$file['name']}.map",
124 'sourceMapURL' => "{$file['name']}.map",
126 // absolute path to a file to write the map to
127 'sourceMapWriteTo' => "{$file['baseDir']}/{$file['name']}.map",
129 // output source contents?
130 'outputSourceFiles' => false,
132 // this is added to the file path.
133 'sourceMapRootpath' => '../',
135 // this is removed from the filepath.
136 'sourceMapBasepath' => $rootDir .'/roojs1/scss'
141 $css = "{$file['baseDir']}/{$file['name']}";
143 echo "Compiling - {$src} To {$css}\n";
145 $scss->setImportPaths($file['scssDir']);
146 $scss->setFormatter('Expanded');
148 file_put_contents($css, $scss->compile("{$file['variables']}\n@import \"{$src}\";"));
151 $min = "{$file['baseDir']}/{$file['minify']}";
155 echo "Minifing - {$src} To {$min}\n";
157 $scss->setFormatter('Crunched');
159 file_put_contents($min, $scss->compile("{$file['variables']}\n@import \"{$src}\";") );
160 } catch (Exception $ex) {
161 echo "scss fatal error: {$ex->getMessage()}\n";