Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/rails_development_boost.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class Railtie < ::Rails::Railtie
else
ActionDispatch::Callbacks.before(:prepend => true) { ActiveSupport::Dependencies.unload_modified_files! }
end


::Sprockets::Environment.prepend(Sprockets::PathCacheEnvironment)
DependenciesPatch.enable_async_mode_by_default!
end
end
Expand Down Expand Up @@ -53,7 +54,9 @@ def self.supports_reload_classes_only_on_change?
autoload :ReferenceCleanupPatch, 'rails_development_boost/reference_cleanup_patch'
autoload :Reloader, 'rails_development_boost/reloader'
autoload :RequiredDependency, 'rails_development_boost/required_dependency'
autoload :Sprockets, 'rails_development_boost/sprockets'
autoload :RoutesLoadedFile, 'rails_development_boost/routes_loaded_file'

autoload :ViewHelpersPatch, 'rails_development_boost/view_helpers_patch'

def self.debug!
Expand Down
6 changes: 6 additions & 0 deletions lib/rails_development_boost/sprockets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module RailsDevelopmentBoost
module Sprockets
autoload :PathCache, 'rails_development_boost/sprockets/path_cache'
autoload :PathCacheEnvironment, 'rails_development_boost/sprockets/path_cache_environment'
end
end
27 changes: 27 additions & 0 deletions lib/rails_development_boost/sprockets/path_cache.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module RailsDevelopmentBoost
module Sprockets
module PathCache
# @!attribute[r] resolve_path_cache
# The path resolution cache. This is keyed by path, and the value is either a string
# containing the resolved path, or false to indicate that it should not be cached.
mattr_reader :resolve_path_cache
@@resolve_path_cache = {}

def resolve(path, options = {})
cached_path = PathCache.resolve_path_cache[path]
return cached_path if cached_path

result = super
return result if cached_path == false || result.first.nil?

raw_path = parse_asset_uri(result.first).first
if Bundler.rubygems.all_specs.any? { |s| raw_path.start_with?(s.full_gem_path) }
PathCache.resolve_path_cache[path] = result
else
PathCache.resolve_path_cache[path] = false
end
result
end
end
end
end
11 changes: 11 additions & 0 deletions lib/rails_development_boost/sprockets/path_cache_environment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module RailsDevelopmentBoost
module Sprockets
module PathCacheEnvironment
def cached
result = super
result.singleton_class.prepend(RailsDevelopmentBoost::Sprockets::PathCache)
result
end
end
end
end