Method: Webpacker::Helper#stylesheet_pack_tag
- Defined in:
- lib/webpacker/helper.rb
#stylesheet_pack_tag(*names, **options) ⇒ Object
Creates a link tag that references the named pack file, 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/javascript/packs/*.js. In production mode, the digested reference is automatically looked up.
Note: If the development server is running and hot module replacement is active, this will return nothing. In that setup you need to configure your styles to be inlined in your JavaScript for hot reloading.
Examples:
# When extract_css is false in webpacker.yml:
<%= stylesheet_pack_tag 'calendar', 'data-turbolinks-track': 'reload' %> # =>
nil
# When extract_css is true in webpacker.yml:
<%= stylesheet_pack_tag 'calendar', 'data-turbolinks-track': 'reload' %> # =>
<link rel="stylesheet" media="screen" href="/packs/calendar-1016838bab065ae1e122.css" data-turbolinks-track="reload" />
143 144 145 146 147 |
# File 'lib/webpacker/helper.rb', line 143 def stylesheet_pack_tag(*names, **) if current_webpacker_instance.config.extract_css? stylesheet_link_tag(*sources_from_manifest_entries(names, type: :stylesheet), **) end end |