getzola / zola

A fast static site generator in a single binary with everything built-in. https://www.getzola.org
https://www.getzola.org
MIT License
14.01k stars 964 forks source link

Compiling every SASS file breaks Bulma. #2108

Open disconsented opened 1 year ago

disconsented commented 1 year ago

Bug Report

Environment

(Arch) Linux

Zola version:

0.17.0

Expected Behavior

zola server/zola build should be able to build a site with Bulma 0.4.0 in the SASS directory.

Current Behaviour

zola build
Building site...
Checking all internal links with anchors.
> Successfully checked 0 internal link(s) with anchors.
-> Creating 0 pages (0 orphan) and 0 sections
[components/site/src/sass.rs:26] &file = "/home/disconsented/WebstormProjects/personal_website/sass/bulma.sass"
[components/site/src/sass.rs:26] &file = "/home/disconsented/WebstormProjects/personal_website/sass/sass/components/media.sass"
[components/site/src/sass.rs:26] &file = "/home/disconsented/WebstormProjects/personal_website/sass/sass/components/card.sass"
[components/site/src/sass.rs:26] &file = "/home/disconsented/WebstormProjects/personal_website/sass/sass/components/pagination.sass"
[components/site/src/sass.rs:26] &file = "/home/disconsented/WebstormProjects/personal_website/sass/sass/components/dropdown.sass"
[components/site/src/sass.rs:26] &file = "/home/disconsented/WebstormProjects/personal_website/sass/sass/components/menu.sass"
[components/site/src/sass.rs:26] &file = "/home/disconsented/WebstormProjects/personal_website/sass/sass/components/navbar.sass"
[components/site/src/sass.rs:26] &file = "/home/disconsented/WebstormProjects/personal_website/sass/sass/components/level.sass"
[components/site/src/sass.rs:26] &file = "/home/disconsented/WebstormProjects/personal_website/sass/sass/components/message.sass"
[components/site/src/sass.rs:26] &file = "/home/disconsented/WebstormProjects/personal_website/sass/sass/components/tabs.sass"
[components/site/src/sass.rs:26] &file = "/home/disconsented/WebstormProjects/personal_website/sass/sass/components/breadcrumb.sass"
[components/site/src/sass.rs:26] &file = "/home/disconsented/WebstormProjects/personal_website/sass/sass/components/panel.sass"
[components/site/src/sass.rs:26] &file = "/home/disconsented/WebstormProjects/personal_website/sass/sass/components/modal.sass"
[components/site/src/sass.rs:26] &file = "/home/disconsented/WebstormProjects/personal_website/sass/sass/utilities/mixins.sass"
[components/site/src/sass.rs:26] &file = "/home/disconsented/WebstormProjects/personal_website/sass/sass/utilities/extends.sass"
Error: Failed to build the site
Error: Error: Undefined mixin.
  ╷
4 │   +control
  │    ^^^^^^^
  ╵

The extra output is from a dbg!() macro I've inserted for debugging.

Step to reproduce

Add Bulma.css + the sass directory from Bulma >= 0.9.0 to a sass directory for a Zola site, then build.

Grass doesn't have any issues compiling bulma.sass but throws an error when trying to compile extends.sass.

Keats commented 1 year ago

So the issue is in grass?

disconsented commented 1 year ago

From my understanding the issue is trying to compile every sass file found, compiling just bulma.sass works as expected in grass and compiling sass/utilities/extends.sass results in the same error from Zola.

For sanities’ sake, I've pulled bulma.sass into its directory, and it fails to compile with grass as expected.

personal_website/foo on  next [✘!+?]
❯ ls -lah
Permissions Size User         Date Modified Name
.rw-r--r--   252 disconsented 20 Feb 17:37  bulma.sass

personal_website/foo on  next [✘!+?]
❯ grass bulma.sass
Error: Can't find stylesheet to import.
  ╷
3 │ @import "utilities/all"
  │         ^^^^^^^^^^^^^^^
  ╵
./bulma.sass:3:9

Maybe only grab top level sass files or allow for specifying a glob pattern to fix this?

Keats commented 1 year ago

I mean, according to Sass any files not starting with _ needs to be compiled in their own files. That should be Bulma fixing their naming (see issue from 2019 about that: https://github.com/jgthms/bulma/issues/2401) not all other projects adding hacks for it.

jonassmedegaard commented 1 year ago

Underscore prefix is indeed a hint that a file is intended only for inclusion, not final rendering on its own. I don't think that is a hard rule, however.

Please provide Zola authors the power to override default behaviour of SASS files, to work around stupid third-parties like Bulma not following conventions.

Keats commented 1 year ago

Adding options or hacks for a single library is not going to happen no.

jonassmedegaard commented 1 year ago

I certainly agree that this should not be a hack specific to bulma.

What I had in mind was a general logic of a) by default compile all SASS files except those beginning with underscore, and b) allow through config option to override that default behavior.

One way this could be structured is with a new option compile_sass_exclude, with default value ["**/_*"].