私は Mac OS X Mountain Lion を実行しており、最近 RVM 経由で Ruby をセットアップしています。次に、正常に動作する Middleman ( http://middlemanapp.com/ ) をインストールしました。構成設定を追加して、プロジェクトのビルドを行うことができました。
私の問題は、Guard を使用して Sass/Compass をコンパイルし、LiveReload にリンクしてブラウザを自動的に更新しようとしたことに起因しています。
私のミドルマンプロジェクトの構造は次のとおりです。
{プロジェクト名}/site/source
(ソースは、同じレベルの「ビルド」フォルダーにコンパイルされる Middleman フォルダーです)
私の gemfile/config.rb/guardfile はここにあります:
{プロジェクト名}/site/
以下にリストされているのは、私の Gemfile、Config.rb、および私の Guardfile です。
Gemfile:
# If you have OpenSSL installed, we recommend updating
# the following line to use "https"
source 'https://rubygems.org'
gem 'middleman', '~>3.0.12'
gem 'sass'
gem 'compass'
gem 'oily_png'
gem 'guard'
gem 'guard-compass'
gem 'guard-shell' # Run shell commands.
gem 'guard-livereload' # Browser reload.
gem 'rb-fsevent', :require => false # Mac OSX
Congid.rb (Middleman ビルド用の構成も含まれていますが、Sass/Compass とは関係ありません)
# Sass options:
# http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#options
sass_options = Hash.new
# Enable Sass inspection directly from the browser.
#
# Chrome Canary support (Applies to Webkit Nightlies as well.):
# http://blog.q42.nl/post/35203391115/debug-sass-and-less-in-webkit-inspector-and-save-css-cha
# Firefox Extension:
# https://addons.mozilla.org/en-US/firefox/addon/firesass-for-firebug
#
# Set to true to enable. Enabling will disable `line_comments`.
#
sass_options[:debug_info] = true
##
# Compass configuration:
# http://compass-style.org/help/tutorials/configuration-reference
# Development is the default environment. When compiling for production, this
# should be flagged as :production. This can be done through the command line
# with the following.
#
# $ compass compile -e production --force
#
environment = :development
sass_dir = 'source/sass'
css_dir = 'source/css'
js_dir = 'source/js'
images_dir = 'source/img'
relative_assets = true
output_style = (environment == :production ? :compressed : :expanded)
ガードファイル
# ~/.guardfile
# More info at https://github.com/guard/guard#readme
notification :off
puts "Using guard file for markweston project."
group :development do
if File.exists?("./config.rb")
# Compile on start.
puts `compass compile --time --quiet`
# https://github.com/guard/guard-compass
guard :compass do
watch(%r{(.*)\.s[ac]ss$})
end
end
## Look for specified files in the current and child directories.
## `find` requires Ruby 1.9 or greater.
require 'find'
if Find.find(Dir.pwd).detect{|dir|dir=~/.+\.(css|js|html?|php|inc|theme)$/}
guard :livereload do
watch(%r{.+\.(css|js|html?|php|inc|theme)$})
end
end
# Uncomment block above and remove this if using Ruby 1.9 or greater.
# https://github.com/guard/guard-livereload.
# guard :livereload do
# watch(%r{.+\.(css|js|html?|php|inc|theme)$})
# end
end
機能する「bundle exec guard」を実行できます。ブラウザで LiveReload を実行すると、端末はブラウザが接続されたことを通知します。
注意すべきことの 1 つは、「bundle exec Guard」を実行した後にこのエラーが発生することです。
/Users/Mark/.rvm/gems/ruby-1.9.3-p385/gems/compass 0.12.2/lib/compass/configuration/inheritance.rb の ["264"] 行目の NoMethodError: activate
現時点でもそれを理解するのに苦労しています。
主な問題は、sass ディレクトリに保持されている .scss ファイルの 1 つに Sass を実際に書き込むと、css ディレクトリで .css にコンパイルされないことです。端末は何も言わず、何も起こりません。構成に問題がありますが、何が原因かわかりません。
誰でも助けてもらえますか?
ありがとう、
マーク。