我的 scss 似乎没有正确编译。下面写的是我在几个博客上找到的配置说明,以及指南针网站本身,但我似乎无法配置scss。
这是我在浏览器控制台中遇到的错误:资源解释为样式表,但使用 MIME 类型应用程序/八位字节流传输:“localhost:4567/stylesheets/dashboard.scss”
服务器.rb
require "compass"
require "sinatra"
require "haml"
configure do
set :haml, {:format => :html5, :escape_html => true}
set :scss, {:style => :compact, :debug_info => false}
Compass.add_project_configuration(File.join(Sinatra::Application.root, 'config', 'compass.rb'))
end
get '/stylesheets/:name.css' do
content_type 'text/css', :charset => 'utf-8'
scss :"stylesheets/#{params[:name]}", Compass.sass_engine_options
end
get '/' do
@workflow_audits = Auditor.new("jspillers").workflow_audits
haml :dashboard
end
配置/指南针.rb
if defined?(Sinatra)
# This is the configuration to use when running within sinatra
project_path = Sinatra::Application.root
environment = :development
else
# this is the configuration to use when running within the compass command line tool.
css_dir = File.join 'public', 'stylesheets'
relative_assets = true
environment = :production
end
# This is common configuration
sass_dir = File.join 'public', 'stylesheets'
images_dir = File.join 'public', 'images'
http_path = "/"
http_images_path = "/images"
http_stylesheets_path = "/stylesheets"
视图/dashboard.erb(标题)
%head
%title Workflow Stuff
%link{ :rel => :stylesheet, :type => "text/scss", :href => "stylesheets/dashboard.scss"}
%link{ :rel => :stylesheet, :href => "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css"}
%script{ :src => "https://code.jquery.com/jquery-2.1.1.js" }
%script{ :src => "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js" }
我的样式表是 public/stylesheets/dashboard.scss。我的 Gemfile 有指南针和 haml。