Class: React::ServerRendering::EnvironmentContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/react/server_rendering/environment_container.rb

Overview

Return asset contents by getting them from a Sprockets::Environment instance.

This is good for Rails development but bad for production because:

  • It compiles the asset lazily, not ahead-of-time

  • Rails 5 / Sprockets 3 doesn’t expose a Sprockets::Environment in production.

Instance Method Summary collapse

Constructor Details

#initializeEnvironmentContainer

Returns a new instance of EnvironmentContainer.



9
10
11
# File 'lib/react/server_rendering/environment_container.rb', line 9

def initialize
  @environment = ::Rails.application.assets
end

Instance Method Details

#find_asset(logical_path) ⇒ Object



13
14
15
# File 'lib/react/server_rendering/environment_container.rb', line 13

def find_asset(logical_path)
  @environment[logical_path].to_s
end