所以我试图在Sinatra应用程序中使用Compass和Asset Pack。我的设置如下:
require 'sinatra'
require 'bundler'
require 'sinatra/assetpack'
require 'sinatra/support'
require 'compass'
class Application < Sinatra::Base
register Sinatra::AssetPack
register Sinatra::CompassSupport
register Sinatra::SimpleNavigation
set :static, true
set :root, File.dirname(__FILE__)
set :public_folder, File.dirname(__FILE__) + '/public'
set :scss, Compass.sass_engine_options
set :scss, { :load_paths => [ "#{Application.root}/assets/css" ] }
Compass.configuration do |config|
config.sass_dir = "assets/css"
config.project_path = root
config.images_dir = "assets/images"
config.http_generated_images_path = "/images"
config.fonts_dir = "assets/fonts"
end
assets {
serve '/fonts', from: 'assets/fonts'
serve '/js', from: 'assets/js' # Default
serve '/css', from: 'assets/css' # Default
serve '/images', from: 'assets/images' # Default
# The second parameter defines where the compressed version will be served.
# (Note: that parameter is optional, AssetPack will figure it out.)
js :app, '/js/app.js', [
'/js/*',
]
css :application, '/css/application.css', [
'/css/style.css'
]
js_compression :jsmin # :jsmin | :yui | :closure | :uglify
css_compression :sass # :simple | :sass | :yui | :sqwish
}
# Routes and things here
end
使用行set :scss, Compass.sass_engine_options
似乎启用了Compass,但这超过了下一行,然后我无法使用SCSS partials,因为它不知道加载路径。将它们放在同一行上具有相同的效果。
TL:DR:我无法让Compass和SCSS Partials与资产包一起工作
答案 0 :(得分:0)
尝试合并:scss选项?看起来你正在用第二套电话覆盖:
set :scss, Compass.sass_engine_options.merge({ :load_paths => [ "#{Application.root}/assets/css" ] })
此外,Compass配置和set
调用应位于configure
块内。