【问题标题】:How do I enable SASS line numbers in CSS output?如何在 CSS 输出中启用 SASS 行号?
【发布时间】:2010-12-21 22:34:38
【问题描述】:

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

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

你能帮帮我吗?

【问题讨论】:

    标签: css ruby sass compass-sass


    【解决方案1】:

    有人推荐了这个猴子补丁:

    # 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

    现在,您必须从 master 分支中拉入 rails-sass。

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

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        【解决方案3】:

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

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

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

        【讨论】:

        • 好的,我在 config.rb 文件中添加了 'line_cmets = false',但仍然没有变化...我正在使用指南针,我做错了什么?
        • 在 compass.config 中,sass_options = { :line_cmets => true }
        • 最近修复了指南针中的一个错误。如果您可以升级到 0.10.0.pre2 或更高版本,它将起作用。或者你可以按照凯尔的方式去做。
        • 成功了!谢谢 kyle 和 chris,我会在稳定版本时更新。
        猜你喜欢
        • 2016-03-25
        • 1970-01-01
        • 2021-01-11
        • 2015-12-08
        • 2015-06-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-11-17
        相关资源
        最近更新 更多