Sha256: 6d83daae0ae547ab94ae6f66e782fbe176f0a464f4f72d7aed5fb54801bdd473

Contents?: true

Size: 714 Bytes

Versions: 4

Compression:

Stored size: 714 Bytes

Contents

module React
  module ServerRendering
    # Get asset content by reading the compiled file from disk using a Sprockets::Manifest.
    #
    # 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 ManifestContainer
      def initialize
        @manifest = ::Rails.application.assets_manifest
      end

      def find_asset(logical_path)
        asset_path = @manifest.assets[logical_path] || raise("No compiled asset for #{logical_path}, was it precompiled?")
        asset_full_path = ::Rails.root.join("public", @manifest.dir, asset_path)
        File.read(asset_full_path)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
react-rails-1.7.1 lib/react/server_rendering/manifest_container.rb
react-rails-1.7.0 lib/react/server_rendering/manifest_container.rb
react-rails-1.6.2 lib/react/server_rendering/manifest_container.rb
react-rails-1.6.1 lib/react/server_rendering/manifest_container.rb