module Sprockets::ManifestUtils
def find_directory_manifest(dirname)
# => "/app/public/assets/.sprockets-manifest-abc123.json"
find_directory_manifest("/app/public/assets")
Examples
dirname - String dirname
Public: Find or pick a new manifest filename for target build directory.
def find_directory_manifest(dirname) entries = File.directory?(dirname) ? Dir.entries(dirname) : [] entry = entries.find { |e| e =~ MANIFEST_RE } || # Deprecated: Will be removed in 4.x entries.find { |e| e =~ LEGACY_MANIFEST_RE } || generate_manifest_path File.join(dirname, entry) end
def generate_manifest_path
all bets are off.
guessing the location. If directory indexes are enabled on the server,
a random hex string is appended to the filename to prevent people from
like Apache. To help in other environments that may not control this,
filename is prefixed with a "." which is usually hidden by web servers
alongside public assets for convenience. To avoid being served, the
Manifests are not intended to be accessed publicly, but typically live
Public: Generate a new random manifest path.
def generate_manifest_path ".sprockets-manifest-#{SecureRandom.hex(16)}.json" end