Class: Railpack::Manifest::Propshaft

Inherits:
Object
  • Object
show all
Defined in:
lib/railpack/manifest.rb

Overview

Propshaft manifest generator for Rails 7+. Creates a simple JSON manifest mapping logical paths to physical files.

Class Method Summary collapse

Class Method Details

.generate(config) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/railpack/manifest.rb', line 15

def self.generate(config)
  outdir = config['outdir']
  return unless outdir && Dir.exist?(outdir)

  manifest = {}

  # Find built assets - Propshaft format
  Dir.glob("#{outdir}/**/*.{js,css}").each do |file|
    next unless File.file?(file)
    relative_path = Pathname.new(file).relative_path_from(Pathname.new(outdir)).to_s

    # Use relative path as logical path for Propshaft
    logical_path = relative_path
    manifest[logical_path] = {
      'logical_path' => logical_path,
      'pathname' => relative_path,
      'digest' => Digest::MD5.file(file).hexdigest
    }
  end

  # Write manifest for Propshaft (Rails 7+ default)
  manifest_path = "#{outdir}/.manifest.json"
  File.write(manifest_path, JSON.pretty_generate(manifest))
  Railpack.logger.debug "📄 Generated Propshaft manifest: #{manifest_path}"
end