我的scss似乎没有正确编译。下面是我在几个博客上找到的配置说明,以及指南针网站本身,但我似乎无法配置scss。
以下是我在浏览器控制台中收到的错误: 资源解释为样式表但使用MIME类型application / octet-stream传输:“localhost:4567 / stylesheets / dashboard.scss”
server.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
配置/ compass.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"
views / 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。