如何在CSS输出中启用SASS行号?

时间:2009-12-01 08:40:05

标签: css ruby sass compass-sass

如果我使用SASS,如何在CSS输出中启用行号?我发现了一篇文章,但我不太明白在哪里进行修改

http://pivotallabs.com/users/damon/blog/articles/765-standup-04-07-2009-we-have-questions#comments

你能帮帮我吗?

3 个答案:

答案 0 :(得分:10)

如果您将此设置为true,则会有一个名为:line_comments的选项,Sass会在您的编译输出中放置行号。

如何设置此选项取决于您使用Sass的方式。如果它位于Rails,Merb或Rack应用程序中,您可以设置Sass::Plugin.options[:line_comments] = true

如果您使用指南针,请在配置文件中设置line_comments = false

答案 1 :(得分:1)

如果您正在使用Sprockets和sprockets-sass gem,您可能需要这样做:

Sprockets::Sass.options[:line_comments] = true

答案 2 :(得分:0)

有人建议这个猴子补丁:

# Had to use this instead as per comment by @glebtv https://github.com/rails/sass-rails/issues/157
module Sass
    class Engine
      def initialize(template, options={})
        @options = self.class.normalize_options(options)
        @options[:debug_info] = true
        @template = template
      end
    end
end

猴子补丁有效,但我认为这样做效果更好:https://github.com/rails/sass-rails/pull/181

现在,您必须从主分支中获取rails-sass。

group :development, :test do
  gem 'sass-rails', '~> 4.0.0', git: 'https://github.com/rails/sass-rails.git', branch: 'master'
end