1

I'm using the Saturn Site theme from Grav (https://getgrav.org/downloads/skeletons) and want to change the background image of the home page (and eventually other styles). In the theme's custom CSS (user/themes/saturn/css/custom.css) I changed the background image, but the new image is not rendered unless I update both custom.css and custom.min.css.

I believe it is inappropriate to change both files; the system should generate a new version of the minified CSS. Reading the Grav docs (https://learn.getgrav.org/themes/asset-manager) I discovered that Grav provides

an Asset Pipeline that can be used to minify and compress assets to reduce the number of browser requests, and also the overall size of the assets.

How do I run this pipeline to update/minify the theme's CSS? Or do I need to install a separate CSS minifying tool?

Additional information: My user/config/system.yaml file includes this:

assets: css_pipeline: false # The CSS pipeline is the unification of multiple CSS resources into one file css_minify: true # Minify the CSS during pipelining css_rewrite: true # Rewrite any CSS relative URLs during pipelining

4

2 回答 2

2

Grav 只会缩小主题中加载的文件。

根据https://github.com/getgrav/grav-theme-saturn/blob/develop/templates/partials/base.html.twigcustom.min.css是加载的 CSS 文件,所以 Grav 会缩小它,而不是custom.css.

您有 3 个解决方案:

  1. 编辑该行,base.html.twig {% do assets.addCss('theme://css/custom.min.css') %} 然后 {% do assets.addCss('theme://css/custom.css') %} 您可以将任何您喜欢的内容添加到 custom.css 中,Grav 会为您缩小它。但是,如果您这样做,base.html.twig当您更新主题时,您所做的更改将会丢失。
  2. 您只需将 CSS 添加到custom.min.css其中,根本不需要缩小它(尽管它的名称是*.min.css),Grav 会帮助您缩小它。这样,custom.min.css当您更新主题时,您的更改仍然会丢失。
  3. 创建此主题的子主题,覆盖base.html.twig并应用上面的第一个或第二个解决方案。这样,当您更新主题时,您的更改不会丢失。然而,这需要 Grav 开发技能。
于 2017-08-19T07:55:00.350 回答
0

在 GRAV 的根目录中尝试运行bin/grav clear. 这也应该更新缩小的 CSS 文件。

于 2017-05-09T23:09:34.990 回答