Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Grunt plugin to inline the contents of a css file Reply To: Grunt plugin to inline the contents of a css file

#256036
Atelierbram
Participant

There is this grunt-copy plugin that I use for inlining CSS in a style-block. So in gruntfile.js within a “copy task” one can copy anything and rename it to something else. Like, for example, copy a prefixed and minified build/css/critical.min.css file to build/inc/critical-css.inc.

Maybe you don’t need this but anyway: a PHP-include within those style tags can output this with the.inc suffix. Or in a template language like twig:

{% if page.page_type == "post" %}<style>{% include "build/inc/critical-css.inc" %}</style>{% endif %}