Question

How can I enable line numbers in CSS output if I am using SASS? I found an article but I didn't quite understand where to make the modifications

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

Could you help me?

Was it helpful?

Solution

There's an option called :line_comments if you set this to true, Sass will place line numbers in your compiled output.

How to set this option depends on how you're using Sass. If it's in a Rails, Merb, or Rack application you can set Sass::Plugin.options[:line_comments] = true.

If you're using compass, set line_comments = false in your configuration file.

OTHER TIPS

If you happen to be using Sprockets and the sprockets-sass gem, you may need to do it like this:

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

Someone suggested this monkey-patch:

# 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

The monkey-patch works, but I think this works even better: https://github.com/rails/sass-rails/pull/181

For now, you have to pull in rails-sass from the master branch.

group :development, :test do
  gem 'sass-rails', '~> 4.0.0', git: 'https://github.com/rails/sass-rails.git', branch: 'master'
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top