Sha256: b6ef091d2ff0415595e293cdf523b12e4ff4f99b375fee83d4459c1a60da5947
Contents?: true
Size: 937 Bytes
Versions: 5
Compression:
Stored size: 937 Bytes
Contents
# frozen_string_literal: true 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 # sprockets-rails < 2.2.2 does not have `application.assets_manifest` def self.compatible? ::Rails.application.respond_to?(:assets_manifest) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems