aboutsummaryrefslogtreecommitdiffstats
path: root/bin/make_css_watch
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-05-31 08:58:54 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-05-31 15:36:08 +0100
commit38e2918987677253b6a337f5287c2e29685b9c78 (patch)
tree730f88f1cdef16d2e3c95cd6b95972277cb6b158 /bin/make_css_watch
parenta2b2bdd3813ad60c97269147efb8f0353becb66c (diff)
Improve CSS compilation.
Move to using libsass via CSS::Sass, and stop using compass, supplying any used mixins directly. This removes the need for any ruby/gem based installation, and greatly increases the speed of compilation. make_css is also enhanced, bringing in the file monitoring previously done by a separate script and improving its dependency monitoring.
Diffstat (limited to 'bin/make_css_watch')
-rwxr-xr-xbin/make_css_watch97
1 files changed, 0 insertions, 97 deletions
diff --git a/bin/make_css_watch b/bin/make_css_watch
deleted file mode 100755
index d15fa3a81..000000000
--- a/bin/make_css_watch
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/usr/bin/env perl
-
-use strict;
-use warnings;
-use feature 'say';
-
-BEGIN {
- use File::Basename qw(dirname);
- use File::Spec;
- my $d = dirname(File::Spec->rel2abs($0));
- require "$d/../setenv.pl";
-}
-
-use Cwd qw(abs_path);
-use File::ChangeNotify;
-use File::Find::Rule;
-use FindBin;
-use Path::Tiny;
-
-my @exts = qw/
- scss
-/;
-
-my @dirs = qw/
- web
-/;
-
-my $filter = do {
- my $exts = join '|', @exts;
- qr/\.(?:$exts)$/
-};
-
-my $watcher = File::ChangeNotify->instantiate_watcher(
- directories => \@dirs,
- filter => $filter,
-);
-
-my $script_compass = 'compass';
-my $script_sass = 'sass';
-my $gem_bin = abs_path("$FindBin::Bin/../../gem-bin");
-if (-f "$gem_bin/compass") {
- $script_compass = "$gem_bin/compass";
- $script_sass = "$gem_bin/sass";
-}
-
-sub title {
- my $what = shift;
- print "\033]2;$what\007\n";
-}
-
-say sprintf "Watching [%s] for %s", (join ',' => @dirs), $filter;
-title 'watching';
-
-while ( my @events = $watcher->wait_for_events() ) {
- my %seen;
- my @update_dirs;
- title 'updating';
- for my $event (@events) {
- my $file = path( $event->path );
- say "$file was updated...";
- my $dir = $file->dirname;
- next if $seen{$dir}++;
-
- if ($dir eq 'web/cobrands/sass/') {
- # contains only partials, so we don't need to update
- # this directory, but we *do* need to update everything else
- push @update_dirs,
- grep {
- ! ($seen{$_}++)
- }
- map {
- path($_)->dirname
- }
- File::Find::Rule->file->name($filter)->in( @dirs );
- }
- else {
- push @update_dirs, $dir;
- }
- }
- for my $dir (@update_dirs) {
- if (-e "$dir/config.rb") {
- system $script_compass,
- 'compile',
- '--output-style' => 'compressed',
- $dir;
- }
- else {
- system $script_sass,
- '--scss',
- '--update',
- '--style' => 'compressed',
- $dir;
- }
- title "$dir updated";
- }
- title 'watching';
-}