我正在编写一个经典风格的 sinatra app,并尝试使用sinatra-assetpack打包我的 scss 文件,但它不起作用。
这是我的主要网络文件:
require 'rubygems'
require 'sinatra'
require 'haml'
require 'sass'
require 'compass'
require 'sinatra/assetpack'
set :root, File.dirname(__FILE__)
set :environment, ENV["RACK_ENV"] || "development"
configure do
Compass.configuration do |config|
config.project_path = File.dirname(__FILE__)
config.sass_dir = 'views/stylesheets'
end
set :haml, { :format => :html5 }
set :scss, Compass.sass_engine_options
assets {
serve '/javascripts', from: 'public/javascripts'
serve '/stylesheets', from: '/stylesheets'
# The second parameter defines where the compressed version will be served.
# (Note: that parameter is optional, AssetPack will figure it out.)
js :lib, '/javascripts/script.js', [
'/javascripts/lib/modernizr-2.5.3.js',
'/javascripts/lib/underscore-min.js',
'/javascripts/lib/slides.min.jquery.js',
'/javascripts/lib/jquery.scrollTo-1.4.2-min.js'
]
css :app, '/stylesheets/screen.css', [
'/stylesheets/screen.css',
'/fonts/meta.css'
]
js_compression :jsmin
css_compression :sass
}
end
我在我的布局文件中使用它:
= css :app, :media => 'screen'
该screen.scss
文件存储在 中/views/stylesheets/screen.scss
,并且meta.css
位于/public/fonts/meta.css
. 引用screen.css
不正确吗?是否应该从不同的目录提供它们?
我的主网络文件中也有这个
get '/stylesheets/screen.css' do
content_type 'text/css', :charset => 'utf-8'
scss :'stylesheets/screen'
end
放入或移除它并没有解决任何问题 - 这条路线是否必要?