Generating critical CSS

I have a custom-built theme, and I’d love to generate critical CSS during build-time.

Has someone done this before? Here’s what I’ve tried -

  1. Critical CSS by Addy Osmani
  2. Penthouse

Both present unique challenges for generating critical CSS for a Ghost build right during the build time -

Critical requires we have the static HTML on hand, which is not possible for Ghost AFAIK. Penthouse on the other hand opens up a page/URL and then calculates the critical CSS (I like this approach better), but that means I’ll need a local dev Ghost server running, which is again difficult to automate as part of my build step.

References -