Rails Asset Pipeline/Compass/SASS在开发模式下的编译速度非常慢 [英] Rails Asset Pipeline/Compass/SASS extremely slow to compile in development mode

查看:88
本文介绍了Rails Asset Pipeline/Compass/SASS在开发模式下的编译速度非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Rails 3.2,我的应用程序中大约加载了40个SASS文件.其中很大一部分是引导程序.

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

任何页面的每次重新加载都需要10秒钟以上的时间.如果我删除<%= stylesheet_link_tag "application", :media => "all" %>页面,则几乎立即加载.

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

调试导致样式缓慢的样式表的最佳方法是什么?还是我有40多个部分.css.scss文件全部在页面刷新时编译的事实?

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?

几乎每个.scss文件的顶部都有一个@import"mixins",它会加载一些基本颜色变量.不知道这是否也会减慢速度,我也不知道如何以其他任何方式在所有.scss文件中使用这些基色...

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...

我想在使用实时重新加载gem之前解决此缓慢问题,如下所述:

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/

推荐答案

原来,fredwu在github上指出了一个问题:

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

我认为这是Sprockets解析器的问题: https://github.com/sstephenson/sprockets/blob/v2.2.2/lib/sprockets/trail.rb#L70-L83

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手动解析资产路径,而.13尝试使用 Sprockets解析器,然后引发异常.

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

临时问题是在您的gemfile中使用以下行:

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

这篇关于Rails Asset Pipeline/Compass/SASS在开发模式下的编译速度非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆