Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created December 23, 2016 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/f6ce0a50b463623f77ec9eabbeea68e8 to your computer and use it in GitHub Desktop.
Save zoffixznet/f6ce0a50b463623f77ec9eabbeea68e8 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# This script compiles site's SASS into CSS
# It requires either the presence of `sass` command (which will be tried first)
# or the CSS::Sass Perl 5 module: https://metacpan.org/pod/CSS::Sass
#
if [ command -v sass >/dev/null 2>&1 ] ; then
sass -t compressed assets/sass/style.scss:html/css/style.css &&
echo "Successfully compiled SASS using 'sass' command" ||
{ echo "Failed to compile SASS with 'sass' command"; exit 1 };
elif [ perl -MCSS::Sass -e '' >/dev/null 2>&1 ] ; then
perl -MData::Dumper -MCSS::Sass -wlE '
my ($css, $err, $stats) = CSS::Sass::sass_compile_file(
"assets/sass/style.scss",
output_style => SASS_STYLE_COMPRESSED
);
if (defined $err) {
print Dumper $stats;
say "Failed to compile sass (see diagnostics above)";
exit 1
};
my $f = "html/css/style.css";
open my $fh, ">", $f or
die "Failed to open $f to write CSS into: $!";
print $fh $css;
' && echo "Successfully compiled SASS using CSS::Sass module" ||
{ echo "Failed to compile SASS with CSS::Sass module"; exit 1 }
else
echo "Need either 'sass' command or CSS::Sass Perl 5 module"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment