使用 FSSM 监控 SASS 文件时出错
我正在监视 WordPress 项目中的主题文件夹以监视 .scss 文件并通过命令行 sass 工具运行它们以创建干净的 .css 文件。
该脚本的工作原理与转换一样,但它无法提供任何输出,因为它收到“FSSM 回调错误”。谁能告诉我为什么会发生这种情况?
#sudo gem install fssm
#sudo gem install haml
# Script to watch a directory for any changes to an scss file and compile it to css in the same place
#
# USAGE: ruby sassy.rb <directory_to_watch>
#
require 'rubygems'
require 'fssm'
#directory = File.join(File.dirname(__FILE__), ARGV.first)
directory = "../wp-content/themes/"
FSSM.monitor(directory, '**/*.scss') do
update do |base, relative|
input = "#{base}/#{relative}"
output = "#{base}/#{relative.gsub!('.scss', '.css')}"
command = "sass --scss --watch #{input}:#{output}"
%x{#{command}}
puts "SASSy regenerated #{input} to #{output}"
end
end
正如我所说,SCSS 被编译为同一目录中的 .css 文件,但错误是:
sy-mbp:_build simon$ ruby sassy.rb
^Csassy.rb:19:in ``': update - /Data/code/eil/wp-content/themes/eil-baseline/style.scss: (FSSM::CallbackError)
from sassy.rb:19
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/path.rb:73:in `call'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/path.rb:73:in `run_callback'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/path.rb:55:in `callback_action'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/path.rb:35:in `update'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/state/directory.rb:38:in `modified'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/state/directory.rb:36:in `each'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/state/directory.rb:36:in `modified'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/state/directory.rb:17:in `refresh'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/backends/fsevents.rb:15:in `add_handler'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/backends/fsevents.rb:14:in `each'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/backends/fsevents.rb:14:in `add_handler'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/backends/rubycocoa/fsevents.rb:107:in `call'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/backends/rubycocoa/fsevents.rb:107:in `initialize'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/backends/fsevents.rb:27:in `call'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/backends/fsevents.rb:27:in `CFRunLoopRun'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/backends/fsevents.rb:27:in `run'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/monitor.rb:20:in `run'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm.rb:18:in `monitor'
from sassy.rb:12
非常感谢帮助!
西蒙
I'm monitoring a theme folder in a WordPress project to watch .scss files and run them througg the command line sass tool to create clean .css files.
The script works in so much as it does the conversion put it fails to provide any output as it gets an 'FSSM callback error'. Can anybody tell me why this happens?
#sudo gem install fssm
#sudo gem install haml
# Script to watch a directory for any changes to an scss file and compile it to css in the same place
#
# USAGE: ruby sassy.rb <directory_to_watch>
#
require 'rubygems'
require 'fssm'
#directory = File.join(File.dirname(__FILE__), ARGV.first)
directory = "../wp-content/themes/"
FSSM.monitor(directory, '**/*.scss') do
update do |base, relative|
input = "#{base}/#{relative}"
output = "#{base}/#{relative.gsub!('.scss', '.css')}"
command = "sass --scss --watch #{input}:#{output}"
%x{#{command}}
puts "SASSy regenerated #{input} to #{output}"
end
end
As I say the SCSS is compiled to a .css file in the same directory but the error is:
sy-mbp:_build simon$ ruby sassy.rb
^Csassy.rb:19:in ``': update - /Data/code/eil/wp-content/themes/eil-baseline/style.scss: (FSSM::CallbackError)
from sassy.rb:19
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/path.rb:73:in `call'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/path.rb:73:in `run_callback'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/path.rb:55:in `callback_action'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/path.rb:35:in `update'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/state/directory.rb:38:in `modified'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/state/directory.rb:36:in `each'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/state/directory.rb:36:in `modified'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/state/directory.rb:17:in `refresh'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/backends/fsevents.rb:15:in `add_handler'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/backends/fsevents.rb:14:in `each'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/backends/fsevents.rb:14:in `add_handler'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/backends/rubycocoa/fsevents.rb:107:in `call'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/backends/rubycocoa/fsevents.rb:107:in `initialize'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/backends/fsevents.rb:27:in `call'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/backends/fsevents.rb:27:in `CFRunLoopRun'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/backends/fsevents.rb:27:in `run'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm/monitor.rb:20:in `run'
from /Library/Ruby/Gems/1.8/gems/fssm-0.2.3/lib/fssm.rb:18:in `monitor'
from sassy.rb:12
Help greatly appreciated!
Simon
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 watchr 重写了它,我发现它非常容易上手。将https://gist.github.com/919884保存到watch_scss.rb,安装watchr gem 并在 wp-content 上方的目录中运行
watchr watch_scss.rb
。Rewrote it using watchr, which I've found is pretty simple to get rolling with. Save https://gist.github.com/919884 to watch_scss.rb, install the watchr gem and run
watchr watch_scss.rb
in a directory above wp-content.使用当前版本的 sass gem,从命令行运行
将处理查找 scss 文件更改并生成 css 版本
http://sass-lang.com/docs/yardoc/file.SASS_CHANGELOG.html#3-0-0-watch
With the current version of the sass gem, running
from the command line will handle looking for scss file changes and generating the css version
http://sass-lang.com/docs/yardoc/file.SASS_CHANGELOG.html#3-0-0-watch