我正在尝试加载CSS3并重置我的SCSS文件中的模块,但是在尝试导入任何特定于Compass的模块时出现错误。
Sinatra App:
require 'rubygems'
require 'sinatra'
require 'sass'
require 'compass'
configure do
set :scss, {:style => :compact, :debug_info => false}
Compass.add_project_configuration(File.join(Sinatra::Application.root, 'config', 'compass.rb'))
end
get '/css/:name.css' do
content_type 'text/css', :charset => 'utf-8'
scss(:"stylesheets/#{params[:name]}" )
end
style.scss:
@import "compass/reset";
@import "compass/css3";
错误讯息:
Sass::SyntaxError at /css/style.css
File to import not found or unreadable: compass/reset. Load path: /Users/work/repos/mysite
我可以安装一个gem来自动提取这些模块,还是我必须将Compass文件移动到我的Sinatra应用程序中?
答案 0 :(得分:4)
在compass.rb中进行了正确配置后,通常足以添加如下内容:
get '/stylesheets/:name.css' do
content_type 'text/css', :charset => 'utf-8'
sass params[:name].to_sym, Compass.sass_engine_options
end
到您的路线。 Sinatra Integration,Sample project或您认为有用的内容:Better Compass integration for Sinatra (extracted from BigBand)
在模块Modular App中,我使用类似:
module Assets
# #Sass/Compass Handler
class Stylesheets < Sinatra::Base
register CompassInitializer
get '/stylesheets/:name.css' do
content_type 'text/css', :charset => 'utf-8'
sass params[:name].to_sym, Compass.sass_engine_options
end
end
end
我的lib
文件夹中有一个文件compass_plugin.rb
module CompassInitializer
def self.registered(app)
require 'sass/plugin/rack'
Compass.configuration do |config|
config.project_path = Padrino.root
config.sass_dir = "app/stylesheets"
config.project_type = :stand_alone
config.http_path = "/"
config.css_dir = "public/stylesheets"
config.images_dir = "public/images"
config.javascripts_dir = "public/javascripts"
config.output_style = :compressed
end
Compass.configure_sass_plugin!
Compass.handle_configuration_change!
app.use Sass::Plugin::Rack
end
end
从Padrino框架
无耻地被盗答案 1 :(得分:0)
我认为你应该只是:
$ gem install compass
$ compass create