Skip to content

Commit 99df9a1

Browse files
committed
support sass compilation in staging
1 parent 8f9166c commit 99df9a1

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

update.php

+1-17
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,8 @@
1515

1616
@unlink($needsUpdateFile);
1717

18-
1918
chdir(ROOT_DIR);
2019

2120
Shell::exec('git fetch && git reset --hard origin/master');
2221

23-
$scss = new \Leafo\ScssPhp\Compiler();
24-
25-
$scss->setImportPaths([ROOT_DIR.'/web/scss']);
26-
27-
$compress = true;
28-
if ($compress)
29-
{
30-
$scss->setFormatter('Leafo\ScssPhp\Formatter\Crunched');
31-
}
32-
else
33-
{
34-
$scss->setFormatter('Leafo\ScssPhp\Formatter\Expanded');
35-
$scss->setLineNumberStyle(Leafo\ScssPhp\Compiler::LINE_COMMENTS);
36-
}
37-
38-
file_put_contents(ROOT_DIR.'/web/css/all.css', $scss->compile(file_get_contents(ROOT_DIR.'/web/scss/all.scss')));
22+
View::compileCss();

view/View.class.php

+21
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,25 @@ public static function getMetaImage()
8989
{
9090
return static::$metaImg ?: '//lbry.io/img/lbry-dark-1600x528.png';
9191
}
92+
93+
public static function compileCss()
94+
{
95+
$scssCompiler = new \Leafo\ScssPhp\Compiler();
96+
97+
$scssCompiler->setImportPaths([ROOT_DIR.'/web/scss']);
98+
99+
$compress = true;
100+
if ($compress)
101+
{
102+
$scssCompiler->setFormatter('Leafo\ScssPhp\Formatter\Crunched');
103+
}
104+
else
105+
{
106+
$scssCompiler->setFormatter('Leafo\ScssPhp\Formatter\Expanded');
107+
$scssCompiler->setLineNumberStyle(Leafo\ScssPhp\Compiler::LINE_COMMENTS);
108+
}
109+
110+
$css = $scssCompiler->compile(file_get_contents(ROOT_DIR.'/web/scss/all.scss'));
111+
file_put_contents(ROOT_DIR.'/web/css/all.css', $css);
112+
}
92113
}

web/index.php

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
{
1010
i18n::register();
1111
Session::init();
12+
if (!IS_PRODUCTION)
13+
{
14+
View::compileCss();
15+
}
1216
Controller::dispatch(strtok($_SERVER['REQUEST_URI'], '?'));
1317
}
1418
catch(Exception $e)

0 commit comments

Comments
 (0)