Skip to content

Commit

Permalink
Add support to override manifest_path as a configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiormoura committed Jun 27, 2024
1 parent af557fb commit 41da5b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
11 changes: 3 additions & 8 deletions lib/propshaft/assembly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def load_path
end

def resolver
@resolver ||= if manifest_path.exist?
Propshaft::Resolver::Static.new manifest_path: manifest_path, prefix: config.prefix
@resolver ||= if config.manifest_path.exist?
Propshaft::Resolver::Static.new manifest_path: config.manifest_path.manifest_path, prefix: config.prefix
else
Propshaft::Resolver::Dynamic.new load_path: load_path, prefix: config.prefix
end
Expand All @@ -32,7 +32,7 @@ def server

def processor
Propshaft::Processor.new \
load_path: load_path, output_path: config.output_path, compilers: compilers
load_path: load_path, output_path: config.output_path, compilers: compilers, manifest_path: config.manifest_path.manifest_path
end

def compilers
Expand All @@ -51,9 +51,4 @@ def reveal(path_type = :logical_path)
asset.send(path_type)
end
end

private
def manifest_path
config.output_path.join(Propshaft::Processor::MANIFEST_FILENAME)
end
end
10 changes: 5 additions & 5 deletions lib/propshaft/processor.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
require "propshaft/output_path"

class Propshaft::Processor
MANIFEST_FILENAME = ".manifest.json"
attr_reader :load_path, :output_path, :compilers, :manifest_path

attr_reader :load_path, :output_path, :compilers

def initialize(load_path:, output_path:, compilers:)
def initialize(load_path:, output_path:, compilers:, manifest_path:)
@load_path, @output_path = load_path, output_path
@manifest_path = manifest_path
@compilers = compilers
end

Expand All @@ -31,7 +30,8 @@ def ensure_output_path_exists


def write_manifest
File.open(output_path.join(MANIFEST_FILENAME), "wb+") do |manifest|
FileUtils.mkdir_p(File.dirname(manifest_path))
File.open(manifest_path, "wb+") do |manifest|
manifest.write load_path.manifest.to_json
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/propshaft/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Railtie < ::Rails::Railtie
config.assets.relative_url_root ||= app.config.relative_url_root
config.assets.output_path ||=
Pathname.new(File.join(app.config.paths["public"].first, app.config.assets.prefix))
config.assets.manifest_path ||= config.assets.output_path.join(".manifest.json")

app.assets = Propshaft::Assembly.new(app.config.assets)

Expand Down

0 comments on commit 41da5b1

Please sign in to comment.