Skip to content

Commit 61f7ae2

Browse files
committed
Tune up webpacker
Introduce new `lcms_engine_javascript_pack_tag` method to be used to include(and compile) lcms-engine based packs. This is a solution to be able to isolate project specific packs and packs created inside the gem. As an alternative we could use the solution provided here - rails/webpacker#348 (comment) This looks more reliable to me.
1 parent de4bf9f commit 61f7ae2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

app/helpers/lcms/engine/application_helper.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ module ApplicationHelper
88
include ViewHelper
99
include ::Webpacker::Helper
1010

11-
def current_webpacker_instance
12-
Lcms::Engine.webpacker
11+
# Use this to include lcms-engine based packs
12+
def lcms_engine_javascript_pack_tag(*names, **options)
13+
entries = names
14+
.map { |name| Lcms::Engine.webpacker.manifest.lookup!(name, type: :javascript) }
15+
.flatten
16+
javascript_include_tag(*entries, **options)
1317
end
1418
end
1519
end

app/views/layouts/lcms/engine/admin.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<%= csrf_meta_tags %>
1414
<%# NOTE: JS served via Assets pipeline should be added first %>
1515
<%= javascript_include_tag 'lcms/engine/admin/application', 'data-turbolinks-track' => 'reload' %>
16-
<%= javascript_pack_tag 'admin' %>
16+
<%= lcms_engine_javascript_pack_tag 'admin' %>
1717
</head>
1818
<body>
1919
<%= render partial: 'lcms/engine/shared/unsupported' %>

0 commit comments

Comments
 (0)