How can I enable Source Maps for Sass in rails 4?

匿名 (未验证) 提交于 2019-12-03 02:00:02

问题:

According to this issue https://github.com/rails/sass-rails/pull/192
sass-rails hasn't support for Sass 3.3 yet.

But it seems that sass-rails-source-maps has been depending on Sass 3.3 since the very beginning. So is there a way to use this gem with sass-rails?

According to the readme with sass-rails-source-maps, Chrome dropped support of the Source Maps files from Sass older than version 3.3.

Does that mean there is no way of using Sass Source Maps with Chrome devtools now?

回答1:

There is a great new drop in replacement for sass-rails, which is not only faster, but also has the option to use inline source-maps.

Just add it to your Gemfile

#gem 'sass-rails', '~> 5.0' gem 'sassc-rails' 

and add the configuration

# config/environments/development.rb config.sass.inline_source_maps = true 

Don't forget to restart your server, then you should see it working in the inspector:

You can find the repo here: https://github.com/sass/sassc-rails



回答2:

I was able to use source maps with Rails 4.1 in this way:

  1. by using the beta of the sass-rails gem (5.0.0.beta1), which isn't always the safest thing to do, and by

  2. adding the "compass-rails" ("2.0.1") and the "compass-rails-source-maps" ("0.0.8") gems. I don't use Compass in this particular project, but the compass-rails-source-maps gem needs the compass-rails gem (obviously), and it worked great for me.

I didn't have much luck with the sass-rails-source-maps gem, but I didn't spend a lot of time with it; perhaps it isn't compatible with the beta sass-rails gem, or something else I'm using.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!