0

I'm looking at the Compass-Sinatra starter file on GitHub. Is there a way to set the output_style for an scss file in Sinatra? Ideally I would like to set the style to :expanded when in development.

I think I'm having trouble understanding how sass(:"stylesheets/#{params[:name]}", Compass.sass_engine_options ) works and where I can set those options.

4

1 回答 1

0

我发现将 output_style 设置添加到 compass.config 文件可以更改 output_style。它可以放在if defined?(Sinatra)块中,也可以放在 compass.config 文件底部的配置块中。

# compass-sinatra-starter/config/compass.config

if defined?(Sinatra)
  # This is the configuration to use when running within sinatra
  project_path = Sinatra::Application.root
  environment = :development
  output_style = :expanded  # This is where you can set the output_style
else
  # this is the configuration to use when running within the compass command line tool.
  css_dir = File.join 'static', 'stylesheets'
  relative_assets = true
  environment = :production
end

# Or if you wanted to have the output_style set for all environments(?) 

# This is common configuration
output_style = :compressed
sass_dir = File.join 'views', 'stylesheets'
images_dir = File.join 'static', 'images'
http_path = "/"
http_images_path = "/images"
http_stylesheets_path = "/stylesheets"

注意:如果您没有看到更改,则更改设置时停止/启动服务器。

例如,我有一个styles.scss文件,views/stylesheets/styles.scss然后如果我去,http://localhost:4567/stylesheets/styles.css我会将浏览器中编译的 .scss 文件转换为 .css。更改output_style, 启动/停止 .cssoutput_style更改的服务器。我不知道使用重新加载器是否可行,但它可能会避免停止/启动?

我发现了其他几个很好的资源。Andrew Stewart 有一篇博文和一个GitHub 模板

最初我试图通过 Sinatra 了解 Sass(scss) 中的媒体查询,并找到了Ben Schwarz 发布的精彩视频,但它并没有涉及到设置的细节。它更多地是关于媒体查询。Ben在 GitHub 上也有源代码。

但似乎AssetPack是提供资产的最佳方式。

于 2013-09-22T12:56:41.043 回答