2 if (php_sapi_name() != 'cli') {
7 $cc = explode('/', $cwd);
8 if (array_pop($cc) !== 'roojs1') {
9 echo "this should be run in roojs1 directory...\n";
13 ini_set('include_path',
14 dirname(__FILE__) . '/../:' .
15 dirname(__FILE__) . '/../../pear:' .
16 ini_get('include_path')
19 $rootDir = dirname(__FILE__) . '/../..';
22 "bootstrap.scss" => array(
23 "scssDir" => "{$rootDir}/roojs1/scss/bootstrap",
24 'baseDir' => "{$rootDir}/roojs1/css-bootstrap4",
25 'name' => 'bootstrap.css',
26 'minify' => 'bootstrap.min.css',
27 'sourceMapRootpath' => '../scss/bootstrap/',
31 "roojs-bootstrap.scss" => array(
32 "scssDir" => "{$rootDir}/roojs1/scss/roojs-bootstrap",
33 'baseDir' => "{$rootDir}/roojs1/css-bootstrap4",
34 'name' => 'roojs-bootstrap-debug.css',
35 'minify' => 'roojs-bootstrap.css',
36 'sourceMapRootpath' => '../scss/roojs-bootstrap/',
37 'variables' => "@import '../bootstrap/functions';\n@import '../bootstrap/variables';"
40 // this is a test to see if we can get this theme to build..
41 // note our classic roojs-bootstrap will need a rebuild as well as it uses different variables.
42 "sb-admin-2.scss" => array(
43 "scssDir" => "{$rootDir}/roojs1/scss/startbootstrap-sb-admin-2",
44 'baseDir' => "{$rootDir}/roojs1/css-bootstrap4",
45 'name' => 'sb-admin-2.css',
46 'minify' => 'sb-admin-2.min.css',
47 'sourceMapRootpath' => '../scss/startbootstrap-sb-admin-2/',
53 require_once 'System.php';
54 $sassc = System::which("sassc");
58 foreach($files as $file => $f) {
60 $tmpFile = tempnam("/tmp/", "scss");
61 file_put_contents($tmpFile, "{$f['variables']}\n@import \"{$file}\";\n");
62 echo file_get_contents($tmpFile);
66 $cmd = "{$sassc} --sourcemap=auto -I {$f['scssDir']} $tmpFile {$f['baseDir']}/{$f['name']}";
69 $cmd = "{$sassc} --style=compressed --sourcemap=auto -I {$f['scssDir']} $tmpFile {$f['baseDir']}/{$f['minify']}";
78 foreach ($files as $src => $file){
80 $css = "{$file['baseDir']}/{$file['name']}";
82 if(!file_exists($css)){
86 $dir = "{$file['baseDir']}/{$file['sourceMapRootpath']}";
88 $variable = "{$dir}variables.less";
90 if(file_exists($variable) && filemtime("{$dir}variables.less") > filemtime($css)){
96 foreach(scandir($dir) as $f) {
98 if (!strlen($f) || $f[0] == '.') {
102 $less = "{$dir}{$f}";
104 if(filemtime($less) > filemtime($css)){
111 echo "{$css} already up-to-date \n";
117 require_once 'HTML/Scss.php';
119 foreach ($files as $src => $file){
121 if(!file_exists($file['scssDir'].'/'. $src)){
122 echo "{$file['scssDir']}/{$src} does not exist...\n";
128 $scss = new HTML_Scss();
130 $scss->setSourceMap(HTML_Scss::SOURCE_MAP_FILE);
131 $scss->setSourceMapOptions(array(
132 'sourceRoot' => $file['sourceMapRootpath'],
134 // an optional name of the generated code that this source map is associated with.
135 'sourceMapFilename' => "{$file['baseDir']}/{$file['name']}.map",
138 'sourceMapURL' => "{$file['name']}.map",
140 // absolute path to a file to write the map to
141 'sourceMapWriteTo' => "{$file['baseDir']}/{$file['name']}.map",
143 // output source contents?
144 'outputSourceFiles' => false,
146 // this is added to the file path.
147 'sourceMapRootpath' => '../',
149 // this is removed from the filepath.
150 'sourceMapBasepath' => $rootDir .'/roojs1/scss'
155 $css = "{$file['baseDir']}/{$file['name']}";
157 echo "Compiling - {$src} To {$css}\n";
159 $scss->setImportPaths($file['scssDir']);
160 $scss->setFormatter('Expanded');
162 file_put_contents($css, $scss->compile("{$file['variables']}\n@import \"{$src}\";"));
165 $min = "{$file['baseDir']}/{$file['minify']}";
169 echo "Minifing - {$src} To {$min}\n";
171 $scss->setFormatter('Crunched');
173 file_put_contents($min, $scss->compile("{$file['variables']}\n@import \"{$src}\";") );
174 } catch (Exception $ex) {
175 echo "scss fatal error: {$ex->getMessage()}\n";