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/',
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';"
38 // this is a test to see if we can get this theme to build..
39 // note our classic roojs-bootstrap will need a rebuild as well as it uses different variables.
40 "sb-admin-2.scss" => array(
41 "scssDir" => "{$rootDir}/roojs1/scss/startbootstrap-sb-admin-2",
42 'baseDir' => "{$rootDir}/roojs1/css-bootstrap4",
43 'name' => 'sb-admin-2.css',
44 'minify' => 'sb-admin-2.min.css',
45 'sourceMapRootpath' => '../scss/startbootstrap-sb-admin-2/',
51 require_once 'System.php';
52 $sassc = System::which("sassc");
56 foreach($files as $file => $f) {
58 $tmpFile = tempnam("/tmp/", "scss");
59 file_put_contents($tmpFile, "{$f['variables']}\n@import \"{$file}\";\n");
60 echo file_get_contents($tmpFile);
64 $cmd = "{$sassc} --sourcemap=auto -I {$f['scssDir']} $tmpFile {$f['baseDir']}/{$f['name']}";
67 $cmd = "{$sassc} --style=compressed --sourcemap=auto -I {$f['scssDir']} $tmpFile {$f['baseDir']}/{$f['minify']}";
76 foreach ($files as $src => $file){
78 $css = "{$file['baseDir']}/{$file['name']}";
80 if(!file_exists($css)){
84 $dir = "{$file['baseDir']}/{$file['sourceMapRootpath']}";
86 $variable = "{$dir}variables.less";
88 if(file_exists($variable) && filemtime("{$dir}variables.less") > filemtime($css)){
94 foreach(scandir($dir) as $f) {
96 if (!strlen($f) || $f[0] == '.') {
100 $less = "{$dir}{$f}";
102 if(filemtime($less) > filemtime($css)){
109 echo "{$css} already up-to-date \n";
115 require_once 'HTML/Scss.php';
117 foreach ($files as $src => $file){
119 if(!file_exists($file['scssDir'].'/'. $src)){
120 echo "{$file['scssDir']}/{$src} does not exist...\n";
126 $scss = new HTML_Scss();
128 $scss->setSourceMap(HTML_Scss::SOURCE_MAP_FILE);
129 $scss->setSourceMapOptions(array(
130 'sourceRoot' => $file['sourceMapRootpath'],
132 // an optional name of the generated code that this source map is associated with.
133 'sourceMapFilename' => "{$file['baseDir']}/{$file['name']}.map",
136 'sourceMapURL' => "{$file['name']}.map",
138 // absolute path to a file to write the map to
139 'sourceMapWriteTo' => "{$file['baseDir']}/{$file['name']}.map",
141 // output source contents?
142 'outputSourceFiles' => false,
144 // this is added to the file path.
145 'sourceMapRootpath' => '../',
147 // this is removed from the filepath.
148 'sourceMapBasepath' => $rootDir .'/roojs1/scss'
153 $css = "{$file['baseDir']}/{$file['name']}";
155 echo "Compiling - {$src} To {$css}\n";
157 $scss->setImportPaths($file['scssDir']);
158 $scss->setFormatter('Expanded');
160 file_put_contents($css, $scss->compile("{$file['variables']}\n@import \"{$src}\";"));
163 $min = "{$file['baseDir']}/{$file['minify']}";
167 echo "Minifing - {$src} To {$min}\n";
169 $scss->setFormatter('Crunched');
171 file_put_contents($min, $scss->compile("{$file['variables']}\n@import \"{$src}\";") );
172 } catch (Exception $ex) {
173 echo "scss fatal error: {$ex->getMessage()}\n";