pilif / sacy

Smarty Asset Compiler (warning: all branches but master are subject to force pushes)
http://pilif.github.com/sacy
MIT License
34 stars 12 forks source link

add support for sassc command (libsass) #29

Open mkuettel opened 5 years ago

mkuettel commented 5 years ago

I installed sassc on my dev env and set the option 'sacy.sass' to /usr/bin/sassc to test this.

I don't know whether it makes sense to switch, I'm still testing performance. But It's quite annoying having to wait ~5s for a simple css change to appear when developing locally. Maybe when this is fast enough we could even use something like livereload, but for that to be useful the compilation time of the css has to improve.

mkuettel commented 5 years ago

I tested the performance using this patch

diff --git a/src/sacy/ext-translators.php b/src/sacy/ext-translators.php
index 8cfbf83..c39c89e 100644
--- a/src/sacy/ext-translators.php
+++ b/src/sacy/ext-translators.php
@@ -18,6 +18,7 @@ abstract class ExternalProcessor{
         }
         $cmd_string = implode(' ', $env_vars). ' ' . $cmd;

+        $start = microtime(true);
         $p = proc_open($cmd_string, $s, $pipes);
         if (!is_resource($p))
             throw new \Exception("Failed to execute $cmd");
@@ -32,6 +33,14 @@ abstract class ExternalProcessor{
         fclose($pipes[2]);

         $r = proc_close($p);
+        $end = microtime(true);
+        $time = $end - $start;
+        file_put_contents("/tmp/sacy_timelog.txt",
+            "Cmd $cmd_string\n" .
+            "Start $start\n" .
+            "End $end\n" .
+            "Time {$time}\n",
+            FILE_APPEND);

         if ($r != 0){
             throw new \Exception("Command returned $r: $err");

I then forced the CSS to recompile by changing the version of dental:

Cmd  /usr/local/bin/sass --cache-location='/tmp' -s --scss  -I '/var/webapps/popscan/pcache/asset_compile/fonts/icon/005741d44bfc79a553d45e3a1fdf543a' -I '/var/webapps/popscan/htdocs/themes/dental/css' -I '/var/webapps/popscan/htdocs/themes/dental/css/modules' -I '/var/webapps/popscan/htdocs/styles/cebus/modern/fragments' -I '/var/webapps/popscan/htdocs/styles/cebus/modern/fragments/tabbed' -I '/var/webapps/popscan/htdocs/themes/dental/css/fragments' -I '/var/webapps/popscan/htdocs/themes/dental/css/custom' -I '/var/webapps/popscan/htdocs'
Start 1560347429.7274
End 1560347430.5281
Time 0.80075788497925
Cmd  /usr/bin/sassc -s   -I '/var/webapps/popscan/pcache/asset_compile/fonts/icon/005741d44bfc79a553d45e3a1fdf543a' -I '/var/webapps/popscan/htdocs/themes/dental/css' -I '/var/webapps/popscan/htdocs/themes/dental/css/modules' -I '/var/webapps/popscan/htdocs/styles/cebus/modern/fragments' -I '/var/webapps/popscan/htdocs/styles/cebus/modern/fragments/tabbed' -I '/var/webapps/popscan/htdocs/themes/dental/css/fragments' -I '/var/webapps/popscan/htdocs/themes/dental/css/custom' -I '/var/webapps/popscan/htdocs'
Start 1560347466.4036
End 1560347466.6419
Time 0.23827719688416

So there is indeed a performance improvement.