Error building site: TOCSS: failed to transform "css/site.sass". How I fixed it?


hugo netlify bulma

I was trying to deploy my Hugo blog to Neltify and deploy failed with the following error:

11:38:07 AM: ┌────────────────────────────────────┐
11:38:07 AM: │ 1. build.command from netlify.toml │
11:38:07 AM: └────────────────────────────────────┘
11:38:07 AM: ​
11:38:07 AM: $ hugo --gc --minify
11:38:08 AM: Building sites … Total in 553 ms
11:38:08 AM: Error: Error building site: TOCSS: failed to transform "css/site.sass" (text/x-sass): SCSS processing failed: file "stdin", line 2, col 1: File to import not found or unreadable: bulma/bulma.
11:38:08 AM: ​
11:38:08 AM: ┌─────────────────────────────┐
11:38:08 AM: │   "build.command" failed    │
11:38:08 AM: └─────────────────────────────┘
11:38:08 AM: ​
11:38:08 AM:   Error message
11:38:08 AM:   Command failed with exit code 255: hugo --gc --minify

I spent about 48 hours to resolve this error and even created a PR for the Hugo theme I use. The repo’s maintainer helped me.

Hugo cannot find Bulma, because Bulma is submodule.

To resolve this issue we need:

Step 1: I have added the following lines to netlify.toml in Hugo project:

[build]
publish = "public"
command = "git submodule update --force --recursive --init --remote && hugo --gc --minify"

Step 2: I changed the Build command in Build settings on Netlify. I set it to:

hugo --gc --minify --buildFuture

The fix was appearing immediately on Netlify:

9:00:27 AM: $ git submodule update --force --recursive --init --remote && hugo --gc --minify
9:00:27 AM: Submodule path 'themes/bare-hugo-theme': checked out 'a4febfc936dabdd8b641dabc10708e2982b81367'
9:00:29 AM: Submodule path 'themes/bare-hugo-theme/assets/css/bulma': checked out 'e9389a982195de66380400c701fb2f1689d45e05'
9:00:30 AM: Submodule path 'themes/bare-hugo-theme/assets/icons': checked out '4c26b644413dd987463f610718958fc873eeb56d'
9:00:31 AM: Building sites …
9:00:31 AM:                    | EN
9:00:31 AM: -------------------+------
9:00:31 AM:   Pages            | 415
9:00:31 AM:   Paginator pages  |   0
9:00:31 AM:   Non-page files   | 262
9:00:31 AM:   Static files     |   3
9:00:31 AM:   Processed images |   0
9:00:31 AM:   Aliases          |   0
9:00:31 AM:   Sitemaps         |   1
9:00:31 AM:   Cleaned          |   0
9:00:31 AM: Total in 911 ms
9:00:31 AM: ​
9:00:31 AM: (build.command completed in 3.8s)
comments powered by Disqus