about summary refs log tree commit diff
path: root/lib/webpacker/helper_extensions.rb
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-11-07 21:47:31 +0100
committerGitHub <noreply@github.com>2020-11-07 21:47:31 +0100
commitcfb16b9b70a50ec5451c9aebb2c35d3a44701311 (patch)
tree6ba298899b376d0c8862d77c1e34339a08dc3121 /lib/webpacker/helper_extensions.rb
parent5a9fc749c3eab8d3c93dd282fa89c20a5cb0e994 (diff)
parente4d62042bdb3b0d675c2367b4c48a2a48647af5e (diff)
Merge pull request #1453 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'lib/webpacker/helper_extensions.rb')
-rw-r--r--lib/webpacker/helper_extensions.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/webpacker/helper_extensions.rb b/lib/webpacker/helper_extensions.rb
new file mode 100644
index 000000000..8f46d7631
--- /dev/null
+++ b/lib/webpacker/helper_extensions.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+module Webpacker::HelperExtensions
+  def javascript_pack_tag(name, **options)
+    src, integrity = current_webpacker_instance.manifest.lookup!(name, type: :javascript, with_integrity: true)
+    javascript_include_tag(src, options.merge(integrity: integrity))
+  end
+
+  def stylesheet_pack_tag(name, **options)
+    src, integrity = current_webpacker_instance.manifest.lookup!(name, type: :stylesheet, with_integrity: true)
+    stylesheet_link_tag(src, options.merge(integrity: integrity))
+  end
+
+  def preload_pack_asset(name, **options)
+    src, integrity = current_webpacker_instance.manifest.lookup!(name, with_integrity: true)
+    preload_link_tag(src, options.merge(integrity: integrity))
+  end
+end
+
+Webpacker::Helper.prepend(Webpacker::HelperExtensions)