-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Webpack manifest to associate asset references per pack #6198
Conversation
**Why**: Since our current approach to list assets required per pack is not scalable, and does not account. changelog: Internal, Build, Generate asset manifest during JavaScript build
Because there's nil-safe navigation, so possible nil values
bf78364
to
197533c
Compare
https: //github.com//pull/6198#discussion_r850804108 Co-Authored-By: Zach Margolis <zbmargolis@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
**Why**: Avoid risks and complication of dealing with executable script tag
1. Parameter not typed (any) 2. Inferred return value is "string", when it can be undefined
def javascript_assets_tag(*names) | ||
assets = AssetSources.get_assets(*names) | ||
if assets.present? | ||
asset_map = assets.index_with { |path| asset_path(path) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect I'll need to revisit this in future work, where we'll want to use this for the design system icon sprite, which can't be loaded across domains, so we'll need to have a way to pass host: asset_host
like we do in IconComponent
:
identity-idp/app/components/icon_component.rb
Line 261 in 5a8af56
asset_path([design_system_asset_path('img/sprite.svg'), '#', icon].join, host: asset_host) |
Thinking we might need to have some sort of allowlist, e.g.
asset_map = assets.index_with { |path| asset_path(path) } | |
asset_map = assets.index_with do |path| | |
asset_path(path, host: SAME_ORIGIN_ASSETS.include?(path) && asset_host) | |
end |
(host
option uses falsey assignment for defaulting)
Why: Since our current approach to list assets required per pack is not scalable, and does not account for packs other than
document-capture
, nor would it support assets deeply referenced via shareable packages (e.g.@18f/identity-components
).What:
getAssetPath
asset_path
, and assigned to a window globalgetAssetPath
pull the mapped path from the window globalTesting Instructions:
Ensure there are no regressions to the use of images in the document capture step, e.g. the "warning" icon after a failed submission, or the ID card animated SVG loading interstitial.