Rails Asset Pipeline/Compass/SASS extremely slow t

2019-09-16 11:13发布

问题:

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