title: How to inline CSS in Rails Header with Webpacker assets
body: <p>I would like to inline some CSS within my html. I have done this in the past with <strong>Sprockets</strong> putting something like that in my layouts/application.html.erb</p>
  
  <pre><code>&lt;style&gt;      
    &lt;%= Rails.application.assets["application.css"].to_s.html_safe %&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>Now I would like to do the same but with CSS assets bundled by <strong>Webpacker</strong>.</p>
  
  <p>I am able to get the path of the file with <code>Webpacker.manifest.lookup("application.css")</code>, but I am missing the latest part to get the content and embed it into the layout</p>
  
  <p><strong>The rationale behind this:</strong></p>
  
  <p>To improve page speed I want to embed my critical CSS into the header of the HTML. Using Webpack and PostCss tools (PurgeCss). I am able to get a very compact very of my CSS for the above the fold of my home page.  </p>
  
  <p>The rest of the CSS is loading asynchronously with the usual packs helpers</p>
  
  <p><strong>Update 1</strong></p>
  
  <p>Here is the link to the article I wrote thanks to the answer.</p>
  
  <p><a href="https://dev.to/adrienpoly/critical-css-with-rails-and-webpacker-sprocketsless-part-1-2bck" rel="nofollow noreferrer">https://dev.to/adrienpoly/critical-css-with-rails-and-webpacker-sprocketsless-part-1-2bck</a></p>