Skip to content

Commit

Permalink
sass.cmd_tpl allows custom scss commands
Browse files Browse the repository at this point in the history
e.g. when switching from one sass compiler to another one in
different environments. Switching from (discontinued) ruby sass
which is the current default to the e.g. node sass can be done
by setting sass.cmd_tpl to "#1 #2 #3 #4 #5 #6".
  • Loading branch information
graste committed Jul 4, 2019
1 parent e1ea12a commit 01ac5e8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
20 changes: 17 additions & 3 deletions app/config/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,22 @@
</settings>

<settings prefix="sass.">
<!--
@see AssetCompiler::getScssCommand(…)
cmd_tpl: defaults to ruby sass command line with the following positional parameters used:
#1: 'sass.env' – prefix of scss command; defaults to env vars
#2: 'sass.cmd' – path to scss binary; defaults to /usr/local/bin/sass
#3: 'sass.style' – defaults to 'compressed'
#4: 'sass.cli_options' – additional cli arguments; defaults to no-cache/unix-newlines/precision=3
and when 'sass.debug' is true it adds: debug-info/line-numbers/line-comments
#5: input file path
#6: output file path
-->
<setting name="cmd_tpl">#1 #2 --scss #3 #4 #5 #6 -E "UTF-8"</setting>
<!-- <setting name="cmd">/opt/ruby/bin/sass</setting> -->
<setting name="style">nested</setting> <!-- nested | expanded | compact | compressed -->
<setting name="style">compressed</setting>
</settings>

<settings prefix="themes.">
Expand Down Expand Up @@ -129,7 +143,7 @@
</settings>
<settings prefix="sass.">
<setting name="cmd">/usr/bin/sass</setting>
<setting name="style">nested</setting>
<setting name="style">compressed</setting>
<setting name="debug">false</setting>
</settings>
<settings prefix="requirejs.">
Expand All @@ -146,7 +160,7 @@
</settings>
<settings prefix="sass.">
<setting name="cmd">/usr/local/bin/sass</setting>
<setting name="style">nested</setting>
<setting name="style">compressed</setting>
<setting name="debug">false</setting>
</settings>
<settings prefix="requirejs.">
Expand Down
12 changes: 10 additions & 2 deletions app/lib/Filter/AssetCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,11 @@ public function getScssCommand($input_file, $output_file, $style = 'compressed')
* '/some/input_file.scss' 'some_output_file.css'
*/
$command = sprintf(
'%s %s --scss %s %s %s %s -E "UTF-8"',
str_replace(
[ '#1', '#2', '#3', '#4', '#5', '#6'],
[ '%1$s', '%2$s', '%3$s', '%4$s', '%5$s', '%6$s'],
AgaviConfig::get('sass.cmd_tpl', '#1 #2 --scss #3 #4 #5 #6 -E "UTF-8"')
),
AgaviConfig::get('sass.env', 'RUBYOPT="" LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8"'),
ProcessUtils::escapeArgument(AgaviConfig::get('sass.cmd', '/usr/local/bin/sass')),
ProcessUtils::escapeArgument('--style=' . $style),
Expand Down Expand Up @@ -303,7 +307,11 @@ public function getScssWatchCommand($input_file, $output_file, $style = 'compres
* '/some/input_file.scss':'some_output_file.css'
*/
$command = sprintf(
'%s %s --watch --scss %s %s %s:%s',
str_replace(
[ '#1', '#2', '#3', '#4', '#5', '#6'],
[ '%1$s', '%2$s', '%3$s', '%4$s', '%5$s', '%6$s'],
AgaviConfig::get('sass.watch_cmd_tpl', '#1 #2 --watch #3 #4 #5:#6')
),
AgaviConfig::get('sass.env', 'RUBYOPT="" LANG=en_US.UTF-8'),
ProcessUtils::escapeArgument(AgaviConfig::get('sass.cmd', '/usr/local/bin/sass')),
ProcessUtils::escapeArgument('--style=' . $style),
Expand Down

0 comments on commit 01ac5e8

Please sign in to comment.