Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/registries/foreman/plugin/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ def webpack_manifest_path
File.file?(manifest_path) ? manifest_path : nil
end

def webpack_remote_entry
webpack_id = id.to_s.tr('-', '_')
remote_entry_path = File.join(path, 'public', 'webpack', webpack_id, "#{webpack_id}_remoteEntry.js")
File.file?(remote_entry_path) ? remote_entry_path : nil
end

def uses_webpack?
path && (File.file?(File.join(path, 'webpack', 'index.js')) || webpack_manifest_path.present?)
path && (File.file?(File.join(path, 'webpack', 'index.js')) || webpack_manifest_path.present? || webpack_remote_entry.present?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arguably, webpack_manifest_path.present? can be dropped now
also, this method hits the disk on every page load, we should cache the result in memory (but scope creep!)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which is exactly what I aimed at in #9834 (comment) but I should have pushed further on this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean "hits the disk" part?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When is path && (File.file?(File.join(path, 'webpack', 'index.js')) false? I only see it as true all the time

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when we use RPMs as we do not ship the webpack folder at all there, as we do not need to compile anything from it on the system where we deploy.

end

private
Expand Down