4

I am using a Rails 4 app with bootstrap. At some point, the assets compilation got borked and now it it takes over a minute to reload a page if i make any changes to the SCSS files. Changing the JS files do not cause this delay. I have no idea what is causing this, but when i tried to just precompile the assets myself, the process takes about 2 seconds to complete. not sure why when it happens on the fly it takes over a minute, sometimes more than 2.

I'm using guard with livereload and when i save a change in a stylesheet, the page is livereloaded but without any stylesheet. if i reload the page, it takes over a minute to render. I'm hoping there's some obvious thing i'm just missing and someone spots it.

While troubleshooting, I switched the configuration so that the scss files are loaded in application.css.scss (with *= require syntax) and then imported the bootstrap variables and mixins in each file, but that was just as slow. I also tried using the CDN bootstrap and then over-writing, but also almost as slow, and it was a headache overwriting so many classes.

the delay is during the rendering of the layout, but it only happens when i make changes to a stylesheet. Any other changes and it loads near instantly.

I have a bunch of design/css work i need to do, and it's nearly impossible with this issue. please help.

(there's probably some other files i should post here as well. just let me know and i'll post it.)

here's my gemfile:

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'

Here's 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

application.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
 */

main.css.scss

/**
*
* 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";

rack-mini-test gem output: rack-mini-test-gem-output

Is there anything else i could add? or any tests to run?

afxjzs
  • 982
  • 3
  • 10
  • 19

1 Answers1

0

in my experience, //= require is faster than @import in development environment, but in some case it could be troublesome

blackbiron
  • 809
  • 10
  • 17
  • Yeah, i swapped over to using mostly //= require and it didn't seem to speed it up at all (maybe 70 seconds instead of 80...big whup) so i put it back. – afxjzs Aug 12 '14 at 18:23