LoginSignup
1
0

More than 5 years have passed since last update.

ブランチ切り替えに(やや)強いscssコマンド

Posted at
scss
#!/usr/bin/env ruby
require 'sass'
require 'sass/exec'

require 'sass/plugin'
%w[
  updating_stylesheets
  not_updating_stylesheet

  creating_directory

  updating_stylesheet
  updated_stylesheet

  template_modified
  template_created
  template_deleted
].each do |cb|
  Sass::Plugin.send "on_#{cb}" do |*args|
    # イベント発生の調査用
    $stderr.puts "on_#{cb} (#{args.join(', ')})"
  end
end
Sass::Plugin.on_compilation_error do |error, template, css|
  puts error.class
  if error.instance_of? Errno::ENOENT
    exec "bundle exec ./scss --watch sass:css"
  end
end

opts = Sass::Exec::Sass.new(ARGV)
opts.parse!
1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0