Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS files not found when vendoring modules in v0.123.x #12137

Closed
markdumay opened this issue Feb 24, 2024 · 4 comments · Fixed by #12139
Closed

CSS files not found when vendoring modules in v0.123.x #12137

markdumay opened this issue Feb 24, 2024 · 4 comments · Fixed by #12139

Comments

@markdumay
Copy link

What version of Hugo are you using (hugo version)?

hugo v0.123.3-a75a659f6fc0cb3a52b2b2ba666a81f79a459376+extended darwin/arm64 BuildDate=2024-02-23T17:09:20Z VendorInfo=brew

Does this issue reproduce with the latest release?

Yes

Context

When upgrading Hugo from v0.122.0 to v0.123.3 I get a CSS transpiler error. Below the full error logs (specific to the Hinode theme):

ERROR render of "taxonomy" failed: execute of template failed: template: partials/head/head.html:8:7: executing "head" at <partialCached "head/stylesheet-core.html" .>: error calling partialCached: "[...]/hinode/layouts/partials/head/stylesheet-core.html:3:3": execute of template failed: template: partials/head/stylesheet-core.html:3:3: executing "partials/head/stylesheet-core.html" at <partial "head/stylesheet.html">: error calling partial: "[...]/hinode/layouts/partials/head/stylesheet.html:60:12": execute of template failed: template: partials/head/stylesheet.html:60:12: executing "partials/head/stylesheet.html" at <partial "head/icons.html" (dict "css" $css)>: error calling partial: "[...]/hinode/layouts/partials/head/icons.html:22:54": execute of template failed: template: partials/head/icons.html:22:54: executing "partials/head/icons.html" at <$css.Content>: error calling Content: TOCSS: failed to transform "css/main.css" (text/x-scss): "[...]/hinode/_vendor/github.com/gethinode/mod-bootstrap/assets/scss/bootstrap.scss:7:1": File to import not found or unreadable: modules/bootstrap/mixins/banner.
ERROR render of "404" failed: execute of template failed: template: partials/head/head.html:8:7: executing "head" at <partialCached "head/stylesheet-core.html" .>: error calling partialCached: "[...]/hinode/layouts/partials/head/stylesheet-core.html:3:3": execute of template failed: template: partials/head/stylesheet-core.html:3:3: executing "partials/head/stylesheet-core.html" at <partial "head/stylesheet.html">: error calling partial: "[...]/hinode/layouts/partials/head/stylesheet.html:60:12": execute of template failed: template: partials/head/stylesheet.html:60:12: executing "partials/head/stylesheet.html" at <partial "head/icons.html" (dict "css" $css)>: error calling partial: "[...]/hinode/layouts/partials/head/icons.html:22:54": execute of template failed: template: partials/head/icons.html:22:54: executing "partials/head/icons.html" at <$css.Content>: error calling Content: TOCSS: failed to transform "css/main.css" (text/x-scss): "[...]/hinode/_vendor/github.com/gethinode/mod-bootstrap/assets/scss/bootstrap.scss:7:1": File to import not found or unreadable: modules/bootstrap/mixins/banner.
ERROR render: failed to render pages: render of "home" failed: execute of template failed: template: partials/head/head.html:8:7: executing "head" at <partialCached "head/stylesheet-core.html" .>: error calling partialCached: "[...]/hinode/layouts/partials/head/stylesheet-core.html:3:3": execute of template failed: template: partials/head/stylesheet-core.html:3:3: executing "partials/head/stylesheet-core.html" at <partial "head/stylesheet.html">: error calling partial: "[...]/hinode/layouts/partials/head/stylesheet.html:60:12": execute of template failed: template: partials/head/stylesheet.html:60:12: executing "partials/head/stylesheet.html" at <partial "head/icons.html" (dict "css" $css)>: error calling partial: "[...]/hinode/layouts/partials/head/icons.html:22:54": execute of template failed: template: partials/head/icons.html:22:54: executing "partials/head/icons.html" at <$css.Content>: error calling Content: TOCSS: failed to transform "css/main.css" (text/x-scss): "[...]/hinode/_vendor/github.com/gethinode/mod-bootstrap/assets/scss/bootstrap.scss:7:1": File to import not found or unreadable: modules/bootstrap/mixins/banner.
Built in 140 ms
Error: error building site: TOCSS: failed to transform "css/main.css" (text/x-scss): "[...]/hinode/_vendor/github.com/gethinode/mod-bootstrap/assets/scss/bootstrap.scss:7:1": File to import not found or unreadable: modules/bootstrap/mixins/banner.

The error only occurs when running hugo mod vendor.

To reproduce

git clone https://github.com/gethinode/hinode.git
cd hinode
hugo mod vendor
hugo server

Removing the _vendor directory solves the TOCSS transpiler error (it doesn't seem to matter if using libsass or dartsass).

rm -rf _vendor
hugo server

Rationale

The Hinode theme vendors its modules to add specific CSS files to a safe list, preventing certain style definitions to be purged from the final CSS file. See config/postcss.config.js for more details. Purge is enabled by setting purge = true in the[style] section of config/_default/params.toml.

@bep
Copy link
Member

bep commented Feb 24, 2024

I just tested this OK:

hugo new site my-hinode-site && cd my-hinode-site
hugo mod init example.com/my-hinode-site
echo "[[module.imports]]" >> hugo.toml
echo "path = 'github.com/gethinode/hinode'" >> hugo.toml
hugo mod vendor
hugo server

You are right that it fails when running the vendored version directly from the theme, but comparing the vendored directories from v0.122 and v0.123 shows that they are the same, which means that it's not the vendoring that's failing.

Hmm.

@bep
Copy link
Member

bep commented Feb 24, 2024

OK, I think I see what's happening now.

@markdumay
Copy link
Author

That’s encouraging!

As a side note, the single reason to vendor the modules is to provide a consistent path for the safe listed files for the purge-css utility. As far as I’m aware, these (external) utilities do not have access to the Hugo mounts. But perhaps there’s a more elegant approach?

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants