Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

Page specific scss

Started by Manuel 8 years ago · 7 replies · 753 views
8 years ago

I am writing some page twig templates and I would like to compile a page-specific scss and add it to assets

Any way to do this?

8 years ago

You can compile the SCSS with whatever toolkit you use, eventually you will be adding the compiled assets to the Twig templates.

Assets (like Javascript and CSS) can be added to Twig templates using

TWIG
{% do assets.addCss('theme://css/pure-0.5.0/grids-min.css', 103) %}

or

TWIG
{% do assets.addJs('theme://js/html5shiv-printshiv.min.js') %}

Look at Asset Manager Documentation for more information.

👍 1
8 years ago

Hi, thanks for reply. I know how to use the Asset Manager but I don't know ho to make Grav compile the script before the template load just how it works normally with themes

8 years ago

hi @manuel_84

I don't think Grav compile scss by itself, Gantry can if i'm right, but i'm not a Gantry guru.
You have to make your own plugin using a scss compiler class like https://github.com/leafo/scssphp/

There is a plugin for Grav https://github.com/getgrav/grav-plugin-scss that use Leafo\ScssPhp\Compiler

then you can have dynamic compilation otherwise use https://learn.getgrav.org/themes/customization#custom-scss-less

hope it helps

8 years ago

Thank you I'll dig more into Gantry to see if I can use its compiler.
Actually I am making a Hydrogen's child theme

8 years ago

The problem is that now in Grav twig files we can add css files with the Asset Manager, but not scss files.
I would like my scss to be added only for specific templates and not compiled with all the rest.

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by Pedro M, 2 months ago
4 193 2 months ago
Themes & Styling · by Ian, 2 months ago
3 90 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 449 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 44 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 123 3 months ago