1
0

helper_extensions.rb 789 B

1234567891011121314151617181920
  1. # frozen_string_literal: true
  2. module Webpacker::HelperExtensions
  3. def javascript_pack_tag(name, **options)
  4. src, integrity = current_webpacker_instance.manifest.lookup!(name, type: :javascript, with_integrity: true)
  5. javascript_include_tag(src, options.merge(integrity: integrity))
  6. end
  7. def stylesheet_pack_tag(name, **options)
  8. src, integrity = current_webpacker_instance.manifest.lookup!(name, type: :stylesheet, with_integrity: true)
  9. stylesheet_link_tag(src, options.merge(integrity: integrity))
  10. end
  11. def preload_pack_asset(name, **options)
  12. src, integrity = current_webpacker_instance.manifest.lookup!(name, with_integrity: true)
  13. preload_link_tag(src, options.merge(integrity: integrity))
  14. end
  15. end
  16. Webpacker::Helper.prepend(Webpacker::HelperExtensions)