Skip to content

Commit 8fff433

Browse files
committed
Add SASS compiler script and make target
- Tries to use `sass` first - If no `sass` is present, tries to compile with CSS::Sass module
1 parent 158db97 commit 8fff433

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ html-nohighlight:
1515
sparse:
1616
perl6 htmlify.p6 --no-highlight --sparse=10
1717

18+
sass:
19+
./util/compile-sass.sh
20+
1821
webdev-build:
1922
perl6 htmlify.p6 --no-highlight --sparse=200
2023

util/compile-sass.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
#
3+
# This script compiles site's SASS into CSS
4+
# It requires either the presence of `sass` command (which will be tried first)
5+
# or the CSS::Sass Perl 5 module: https://metacpan.org/pod/CSS::Sass
6+
#
7+
8+
if command -v sass >/dev/null 2>&1; then
9+
sass -t compressed assets/sass/style.scss:html/css/style.css &&
10+
echo "Successfully compiled SASS using 'sass' command" ||
11+
{ echo "Failed to compile SASS with 'sass' command"; exit 1; }
12+
elif perl -MCSS::Sass -e '' >/dev/null 2>&1 ; then
13+
perl -MData::Dumper -MCSS::Sass -wlE '
14+
my ($css, $err, $stats) = CSS::Sass::sass_compile_file(
15+
"assets/sass/style.scss",
16+
output_style => SASS_STYLE_COMPRESSED
17+
);
18+
if (defined $err) {
19+
print Dumper $stats;
20+
say "Failed to compile sass (see diagnostics above)";
21+
exit 1
22+
};
23+
my $f = "html/css/style.css";
24+
open my $fh, ">", $f or
25+
die "Failed to open $f to write CSS into: $!";
26+
print $fh $css;
27+
' && echo "Successfully compiled SASS using CSS::Sass module" ||
28+
{ echo "Failed to compile SASS with CSS::Sass module"; exit 1; }
29+
else
30+
echo "Need either 'sass' command or CSS::Sass Perl 5 module"
31+
exit 1;
32+
fi

0 commit comments

Comments
 (0)