Rename remaining occurrences of webpacker to shakapacker

This commit is contained in:
Sebastian Serth
2023-09-01 19:39:51 +02:00
parent 07201e7a29
commit ac92385dd7
5 changed files with 10 additions and 11 deletions

View File

@ -0,0 +1,31 @@
# frozen_string_literal: true
module Shakapacker::SriManifestExtensions
def lookup(name, pack_type = {})
asset = super
augment_with_integrity asset, pack_type
end
def lookup_pack_with_chunks(name, pack_type = {})
assets = super
assets.map do |asset|
augment_with_integrity asset, pack_type
end
end
def augment_with_integrity(asset, _pack_type = {})
if asset.respond_to?(:dig) && asset['integrity']
{src: asset['src'], integrity: asset['integrity']}
elsif asset.respond_to?(:dig)
asset['src']
else
asset
end
end
end
if Shakapacker::Manifest.ancestors.map(&:name).exclude?(Shakapacker::SriManifestExtensions.name)
Shakapacker::Manifest.prepend(Shakapacker::SriManifestExtensions)
end