Ruby on rails Rails 4资产编译在开发模式下非常慢(>;1分钟)。如何排除故障?
我正在使用Rails 4应用程序和引导。在某个时候,资产编译被破坏了,现在如果我对SCSS文件进行任何更改,重新加载一个页面需要一分钟。更改JS文件不会导致此延迟。我不知道是什么导致了这种情况,但当我试图自己预先编译这些资产时,这个过程大约需要2秒钟才能完成。不知道为什么在飞行中发生这种情况需要一分钟,有时超过2分钟 我在livereload中使用guard,当我在样式表中保存更改时,页面是livereloaded的,但没有任何样式表。如果我重新加载页面,则渲染需要一分钟。我希望有一些明显的东西我只是错过了,有人发现它 在进行故障排除时,我切换了配置,以便将scss文件加载到application.css.scss(使用Ruby on rails Rails 4资产编译在开发模式下非常慢(>;1分钟)。如何排除故障?,ruby-on-rails,twitter-bootstrap,ruby-on-rails-4,sass,asset-pipeline,Ruby On Rails,Twitter Bootstrap,Ruby On Rails 4,Sass,Asset Pipeline,我正在使用Rails 4应用程序和引导。在某个时候,资产编译被破坏了,现在如果我对SCSS文件进行任何更改,重新加载一个页面需要一分钟。更改JS文件不会导致此延迟。我不知道是什么导致了这种情况,但当我试图自己预先编译这些资产时,这个过程大约需要2秒钟才能完成。不知道为什么在飞行中发生这种情况需要一分钟,有时超过2分钟 我在livereload中使用guard,当我在样式表中保存更改时,页面是livereloaded的,但没有任何样式表。如果我重新加载页面,则渲染需要一分钟。我希望有一些明显的东西
*=require
语法)中,然后在每个文件中导入引导变量和mixin,但速度同样慢。我还尝试使用CDN引导,然后过度编写,但速度也几乎一样慢,覆盖这么多类让人头疼
延迟发生在布局的呈现过程中,但只有在我更改样式表时才会发生。任何其他更改,它几乎立即加载
我有一大堆的设计/css工作要做,这几乎是不可能的。请帮忙
(可能还有一些其他文件我也应该在这里发布。请告诉我,我会发布的。)
这是我的档案:
source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=networkrf
gem 'rails', '4.0.1'
gem 'pg', '0.15.1'
gem 'bootstrap-sass', '~> 3.2.0'
gem 'sass-rails', '>= 3.2'
gem 'autoprefixer-rails'
gem 'bcrypt-ruby', '3.1.2'
gem 'faker', '1.1.2'
gem 'will_paginate', '3.0.4'
gem 'bootstrap-will_paginate', '0.0.9'
gem 'font-awesome-rails'
gem 'httparty'
gem 'gmaps4rails'
gem 'geocoder'
gem 'sprockets_better_errors'
group :development, :test do
gem 'thin'
end
group :development, :test do
gem 'rspec-rails', '2.13.1'
gem 'guard-rspec', '2.5.0'
gem 'spork-rails', github: 'sporkrb/spork-rails'
gem 'childprocess', '0.3.6'
gem 'guard-livereload', require: false
gem 'guard-spork', '1.5.0'
gem 'rack-livereload'
gem 'rb-fsevent', require: false
gem 'factory_girl_rails', '4.2.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
gem 'growl', '1.0.3'
gem 'capybara-screenshot'
gem 'launchy'
end
# gem 'sass-rails', '4.0.0'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.0'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'rails_12factor'
gem 'unicorn'
gem 'newrelic_rpm'
end
# gem 'fog'
# gem 'rmagick', '2.13.2'
# gem 'carrierwave'
这是development.rb
Networkrf::Application.configure do
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = false
config.active_support.deprecation = :log
config.active_record.migration_error = :page_load
config.assets.compress = false
config.assets.debug = true
config.middleware.insert_after(ActionDispatch::Static, Rack::LiveReload)
config.assets.raise_production_errors = true
end
application.rb
require File.expand_path('../boot', __FILE__)
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
require "csv"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)
module Networkrf
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
end
end
main.css.scss
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require font-awesome
*= require main
*/
/**
*
* Loads all stylesheets for the application in order
*
**/
@import "bootstrap-custom";
@import "variables";
@import "theme";
@import "base";
@import "components";
@import "nav";
@import "home";
@import "scenes";
@import "custom";
@import "typography";
@import "utility";
机架小型测试gem输出:
还有什么我可以补充的吗?或者运行任何测试?根据我的经验,
/=require
比开发环境中的@import
要快,但在某些情况下可能会很麻烦是的,我改用了大部分//=require,但它似乎根本没有加快速度(可能是70秒,而不是80秒……大喘息),所以我把它放回去了。