Fontawesome not displayed wit Assets pipeline enabled

Use @import ‘fontawesome-all.min.css’; in main.css appears to be incompatible with Grav’s CSS pipeline option. Using this option greatly improves lighthouse performance and testing, but when I activate it, in the Editorial theme (which calls Fontawesome fonts with the @import option), these fonts do not appear.

grav_assets_pipeline

The only option I have to use the CSS pipeline option is to add the sources in base.html.twig, like any other assets:

{% do assets.addCss('theme://assets/css/fontawesome-all.min.css') %}

Is this a Grav bug or am I doing something wrong in the site settings?

I finally think I found a solution to this problem, which involves modifying the Pipeline.php file inside system/src/Grav/Common/Assets:

I added these lines before line 273:

// Check if it's an @import statement, and if so, don't modify it
            if (strpos($matches[0], '@import') !== false) {
                return $matches[0];
            }

This way, lines in CSS files containing @import are not removed when CSS piping is performed.

@rhuk, could you do some tests and confirm for me that this fixes the problem for good?

See Github Pipeline::cssRewrite() does not rewrite @import 'mystyle.css'; · Issue #3749 · getgrav/grav · GitHub

1 Like

Thanks so much @anon76427325.

Good job, as always.

Now all that remains is for the PR to be integrated into the next version of Grav (there is a long list of PRs and pending issues)