Rails Asset Pipeline/Compass/SASS extremely slow to compile in development mode

大兔子大兔子 提交于 2019-12-12 05:52:04

问题


Using Rails 3.2, I have approximately 40 SASS files loading in my app. A large chunk of it is bootstrap.

Each reload of any page takes 10+ seconds. If I remove <%= stylesheet_link_tag "application", :media => "all" %> pages load almost instantly.

What's the best way to debug which stylesheets are causing the slowness? Or is it just the fact that I have 40+ partial .css.scss files which are all compiled on page refresh?

I have an @import "mixins" at the top of almost every .scss file, which loads some base color variables. Not sure if this might be slowing things down as well, nor do I know how to get these base colors to be available in all .scss files any other way...

I'd like to get this slowness fixed before using a live-reload gem, like mentioned here: http://blog.55minutes.com/2013/01/lightning-fast-sass-reloading-in-rails-32/


回答1:


This gem will help:

gem 'rails-dev-tweaks', '~> 0.6.1'

SOURCE




回答2:


Turns out there is an issue as pointed out by fredwu on the rails github:

I believe it's an issue with Sprockets' resolver: https://github.com/sstephenson/sprockets/blob/v2.2.2/lib/sprockets/trail.rb#L70-L83

Rails .12 resolves the asset paths manually whereas .13 tries to use Sprockets resolver, which then throws an exception.

The interim issue is to use the following line in your gemfile:

gem 'rails', git: "git://github.com/rails/rails.git", branch: "3-2-stable"

https://github.com/rails/rails/issues/9803



来源:https://stackoverflow.com/questions/16290879/rails-asset-pipeline-compass-sass-extremely-slow-to-compile-in-development-mode

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