我试图让Bootstrap的Less文件与Sinatra AssetPack一起工作,但我遇到了Less解析器错误。这些错误让我相信通过bootstrap.less导入的less文件彼此不知道。
我有一个app.rb文件:
require 'sinatra/base'
require 'sinatra/assetpack'
class App < Sinatra::Base
set :root, File.dirname(__FILE__)
register Sinatra::AssetPack
assets do
css :bootstrap, [
'/css/bootstrap.css'
]
end
get '/' do
erb :index
end
# start the server if ruby file executed directly
run! if app_file == $0
end
我已将所有的Bootstrap less文件复制到
/app/css
目录中,并修改了bootstrap.less文件,使每个@import语句以.css结尾(实际文件扩展名未更改)。我还将所有内容上传到Github: https://github.com/elevine/sinatra-assetpack-bootstrap
以下是我遇到的错误的堆栈跟踪的前半部分: Less::ParseError - .tab-focus is undefined:
at /users/elevine/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib/less/js/lib/less/parser.js:385:31
/users/elevine/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib/less/parser.rb:57:in `block in to_css'
/users/elevine/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib/less/java_script/v8_context.rb:90:in `block in do_lock'
/users/elevine/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib/less/java_script/v8_context.rb:88:in `do_lock'
/users/elevine/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib/less/java_script/v8_context.rb:60:in `lock'
/users/elevine/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib/less/java_script/v8_context.rb:30:in `exec'
/users/elevine/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib/less/java_script.rb:26:in `exec'
/users/elevine/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib/less/parser.rb:57:in `to_css'
/users/elevine/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/tilt-1.3.3/lib/tilt/css.rb:68:in `evaluate'
/users/elevine/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/tilt-1.3.3/lib/tilt/template.rb:76:in `render'
/users/elevine/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:686:in `render'
/users/elevine/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/sinatra-assetpack-0.0.11/lib/sinatra/assetpack/class_methods.rb:71:in `block (3 levels) in add_individual_routes!'
/users/elevine/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/tilt-1.3.3/lib/tilt.rb:127:in `fetch'
/users/elevine/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/sinatra-assetpack-0.0.11/lib/sinatra/assetpack/class_methods.rb:70:in `block (2 levels) in add_individual_routes!'
.tab-focus
在 mixins.less 中定义,此错误源于 reset.less,reset.less 是 bootstrap.less 中的第一个导入。我尝试重新排列导入的顺序,但并没有解决问题。
在这种设置下,是否可能使 bootstrap.less 中的 @import 语句正常工作?