-
Notifications
You must be signed in to change notification settings - Fork 4
/
cssCompile.php
36 lines (28 loc) · 943 Bytes
/
cssCompile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
require_once __DIR__ . '/vendor/leafo/scssphp/scss.inc.php';
buildCss();
function buildCss()
{
$src = __DIR__ . '/src/BusinessLogic/Resources/scss';
$dst = __DIR__ . '/src/BusinessLogic/Resources/css';
$scss = new scssc();
$scss->setImportPaths('src/BusinessLogic/Resources/scss/');
$scss->setFormatter('scss_formatter');
createDir($dst);
$dstFileName = $dst . '/app.css';
file_put_contents($dstFileName, '');
$compiledCss = $scss->compile(file_get_contents("{$src}/app.scss"));
$existingContent = file_get_contents($dstFileName);
file_put_contents($dstFileName, $existingContent . $compiledCss);
}
/**
* Creates directory.
*
* @param string $destination
*/
function createDir($destination)
{
if (!file_exists($destination) && !mkdir($destination) && !is_dir($destination)) {
throw new RuntimeException(sprintf('Directory "%s" was not created', $destination));
}
}