Skip to content

Instantly share code, notes, and snippets.

@Caaz
Created January 24, 2016 12:10
Show Gist options
  • Save Caaz/09fd4d57159e8a872364 to your computer and use it in GitHub Desktop.
Save Caaz/09fd4d57159e8a872364 to your computer and use it in GitHub Desktop.
SCSS Compiler!
#!/usr/bin/perl
use warnings;
use strict;
my %updated;
sub compile_scss {
# Get our list of files
my @files = <./scss/*.scss>;
# Do nothing if there aren't even any files
return 0 if(!@files);
# Make sure we even have sass available to us.
die "sass command not found! Install Sass!" if(!`which sass`);
# println("SCSS");
# Make our css directory if it's not there already.
mkdir("./css") if(!-e "./css");
# Iterate through our scss files.
for(@files) {
my $filename; ($filename = $_) =~ s/.*\/(.*?).[^\.]+?$/$1/g;
# Skip files prefixed with _, I use those for importing!
next if($filename =~ /^_/i);
my $time = (stat($_))[9];
next if(($updated{$_}) && ($updated{$_} == $time));
$updated{$_} = $time;
print "Compiling $filename - $time\n";
system("sass --scss --sourcemap=none $_ ./css/$filename.css");
}
return 1;
}
while(sleep(1)) { compile_scss(); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment