class React::ServerRendering::YamlManifestContainer

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)

Public Class Methods

compatible?() click to toggle source
# File lib/react/server_rendering/yaml_manifest_container.rb, line 17
def self.compatible?
  ::Rails::VERSION::MAJOR == 3
end
new() click to toggle source
# File lib/react/server_rendering/yaml_manifest_container.rb, line 8
def initialize
  @assets = YAML.load_file(public_asset_path('manifest.yml'))
end

Public Instance Methods

find_asset(logical_path) click to toggle source
# 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

Private Instance Methods

public_asset_path(asset_name) click to toggle source
# File lib/react/server_rendering/yaml_manifest_container.rb, line 23
def public_asset_path(asset_name)
  asset_path = File.join('public', ::Rails.application.config.assets.prefix, asset_name)
  ::Rails.root.join(asset_path)
end