Method: Webpacker::Helper#javascript_pack_tag

Defined in:
lib/webpacker/helper.rb

#javascript_pack_tag(*names, **options) ⇒ Object

Creates script tags that reference the js chunks from entrypoints when using split chunks API, as compiled by webpack per the entries list in package/environments/base.js. By default, this list is auto-generated to match everything in app/packs/entrypoints/*.js and all the dependent chunks. In production mode, the digested reference is automatically looked up. See: webpack.js.org/plugins/split-chunks-plugin/

Example:

<%= javascript_pack_tag 'calendar', 'map', 'data-turbolinks-track': 'reload' %> # =>
<script src="/packs/vendor-16838bab065ae1e314.chunk.js" data-turbolinks-track="reload"></script>
<script src="/packs/calendar~runtime-16838bab065ae1e314.chunk.js" data-turbolinks-track="reload"></script>
<script src="/packs/calendar-1016838bab065ae1e314.chunk.js" data-turbolinks-track="reload"></script>
<script src="/packs/map~runtime-16838bab065ae1e314.chunk.js" data-turbolinks-track="reload"></script>
<script src="/packs/map-16838bab065ae1e314.chunk.js" data-turbolinks-track="reload"></script>

DO:

<%= javascript_pack_tag 'calendar', 'map' %>

DON'T:

<%= javascript_pack_tag 'calendar' %>
<%= javascript_pack_tag 'map' %>

98
99
100
# File 'lib/webpacker/helper.rb', line 98

def javascript_pack_tag(*names, **options)
  javascript_include_tag(*sources_from_manifest_entrypoints(names, type: :javascript), **options)
end