Skip to content

Needs additional guidance around feeding getBundle through a minifier #7

Description

@zachleat

If you run getBundle output through a minifier before the transform gets to it, it will get removed!

Specifically this quick tip: https://www.11ty.dev/docs/quicktips/inline-css/#capture-and-minify

<!-- capture the CSS content as a Nunjucks variable -->
{% set css %}
  {% include "sample.css" %}
  {% getBundle "css" %}
{% endset %}
<!-- feed it through our cssmin filter to minify -->
<style>
  {{ css | cssmin | safe }}
</style>

Workaround is to move the bundle outside of the css minification pipeline (and optionally use a bundle transform to minify instead):

<!-- capture the CSS content as a Nunjucks variable -->
{% set css %}
  {% include "sample.css" %}
{% endset %}
<!-- feed it through our cssmin filter to minify -->
<style>
  {{ css | cssmin | safe }}
</style>
<style>{% getBundle "css" %}</style>

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Enhancement.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions