Module: Webpacker::Helper
- Defined in:
- lib/webpacker/helper.rb
Instance Method Summary collapse
-
#javascript_pack_tag(name, **options) ⇒ Object
Creates a script tag that references the named pack file, as compiled by Webpack per the entries list in config/webpack/shared.js.
Instance Method Details
#javascript_pack_tag(name, **options) ⇒ Object
Creates a script tag that references the named pack file, as compiled by Webpack per the entries list in config/webpack/shared.js. By default, this list is auto-generated to match everything in app/javascript/packs/*.js. In production mode, the digested reference is automatically looked up.
Examples:
# In development mode:
<%= javascript_pack_tag 'calendar', 'data-turbolinks-track': 'reload' %> # =>
<script src="/packs/calendar.js" data-turbolinks-track="reload"></script>
# In production mode:
<%= javascript_pack_tag 'calendar', 'data-turbolinks-track': 'reload' %> # =>
<script src="/packs/calendar-1016838bab065ae1e314.js" data-turbolinks-track="reload"></script>
17 18 19 |
# File 'lib/webpacker/helper.rb', line 17 def javascript_pack_tag(name, **) javascript_include_tag(Webpacker::Source.new(name).path, **) end |