sintaxi / harp

Static Web Server/Generator/Bundler
http://harpjs.com
5k stars 346 forks source link

Include CSS as inline style using <partial>? #599

Closed x5hwuk7nc6jsudcc closed 4 years ago

x5hwuk7nc6jsudcc commented 7 years ago

How to include compiled SCSS file (or even just straight CSS file) as an inline-style in the document head?

Accelerated Mobile Pages (AMP) requires CSS be provided this way (not as link to stylesheet).

This code doesn't work:

  <style amp-custom>
    <%- partial("/_framework/_style.scss") %>
  </style>

Any ideas? Thanks.

justindujardin commented 7 years ago

I modified my forks of harp/terraform to support partial LESS files. It works fine for my usage but it breaks some tests and I won't support it, so your mileage may vary.

Diff: https://github.com/sintaxi/terraform/compare/master...justindujardin:master

Install:

npm i --save git+https://github.com/justindujardin/harp.git

Use exactly like your original post except with a less file.