Class: React::ServerRendering::YamlManifestContainer
- Inherits:
-
Object
- Object
- React::ServerRendering::YamlManifestContainer
- Defined in:
- lib/react/server_rendering/yaml_manifest_container.rb
Overview
Get asset content by reading the compiled file from disk using the generated manifest.yml file
This is good for Rails production when assets are compiled to public/assets but sometimes, they’re compiled to other directories (or other servers)
Class Method Summary collapse
Instance Method Summary collapse
- #find_asset(logical_path) ⇒ Object
-
#initialize ⇒ YamlManifestContainer
constructor
A new instance of YamlManifestContainer.
Constructor Details
#initialize ⇒ YamlManifestContainer
Returns a new instance of YamlManifestContainer.
8 9 10 |
# File 'lib/react/server_rendering/yaml_manifest_container.rb', line 8 def initialize @assets = YAML.load_file(public_asset_path('manifest.yml')) end |
Class Method Details
.compatible? ⇒ Boolean
17 18 19 |
# File 'lib/react/server_rendering/yaml_manifest_container.rb', line 17 def self.compatible? ::Rails::VERSION::MAJOR == 3 end |
Instance Method Details
#find_asset(logical_path) ⇒ Object
12 13 14 15 |
# File 'lib/react/server_rendering/yaml_manifest_container.rb', line 12 def find_asset(logical_path) asset_path = @assets[logical_path] || raise("No compiled asset for #{logical_path}, was it precompiled?") File.read(public_asset_path(asset_path)) end |