okkur / syna

Highly customizable open source theme for Hugo based static websites
https://syna.okkur.org/demo/
Apache License 2.0
250 stars 133 forks source link

Error building site with v0.17.3 #813

Closed Rado-1 closed 3 years ago

Rado-1 commented 4 years ago

Is this a BUG REPORT or FEATURE REQUEST?: bug

What happened:

With update of my webpage to Syna v0.17.3, the following error started to occur while running hugo server:

Building sites … WARN 2020/07/26 19:34:36 .File.Dir on zero object. Wrap it in if or with: {{ with     .File }}{{ .Dir }}{{ end }}
Built in 449 ms
Error: Error building site: POSTCSS: failed to transform "style.css" (text/css): resource "scss/styles/index.scss_02bf14281ac065540fcc7ecc15ca70a4" not found in file cache

BTW the same happens also on your okkur / syna-start project.

What you expected to happen:

No error occurs.

How to reproduce it (as minimally and precisely as possible):

  1. Checkout syna-start with
    git clone --recurse-submodules https://git.okkur.org/syna-start
  2. Run hugo server.

Anything else we need to know?:

Environment:

stp-ip commented 4 years ago

Thanks for reporting. cc @mpourismaiel

mpourismaiel commented 4 years ago

I'm running reproduction steps with Hugo v0.74.3 extended linux version and Syna v0.17.3 and it's working fine. Any changes I should apply that I'm not aware of?

stp-ip commented 4 years ago

Try with a clean JS stack aka no packages installed. I assume that might be the culprit. It tries to rebuild the CSS, which fails and the error of the missing cache is hiding the actual issue I assume.

mpourismaiel commented 4 years ago

I tried to build on a new clone of syna-start. So there's no changes and empty node_modules and everything.

Rado-1 commented 4 years ago

Cannot Windows cause the problem? I can always reproduce is as described above. Maybe one detail which should not influence the result, I removed the enableGitInfo = true line from config.toml.

stp-ip commented 4 years ago

The current assumption is that a specific package is necessary. postcss-cli, if this isn't there Hugo fails, but gives the wrong error. Mahdi is still investigating so.

mpourismaiel commented 4 years ago

Sorry for the delay. The problem is indeed postcss. For now, please install postcss-cli globally by running npm install -g postcss-cli.

@stp-ip I can't figure out anyway around removing postcss functions and activating them by a configuration. It of course needs further documentation. Is that a good approach?

stp-ip commented 4 years ago

Mhh we can't check for postcss config being available. How about adding 1 config value within config.toml?

postcss = true (aka enable postcss - default false)

Then we can document that for postcss and purgecss one needs to have postcss-cli installed and add the value. That would make us not break people not using postcss.

Thoughts?

Rado-1 commented 4 years ago

Does it mean that everyone using Hugo with the Syna theme should install also Node.js with postcss-cli? This would be very restrictive external dependency, I think.

stp-ip commented 4 years ago

As long as no CSS needs to be changed using Hugo (non extended version) should be fine.

We are trying to wall off that postcss part within Hugo and add a config to enable it so that even with rebuilding CSS no non hugo dependency is necessary.

Maybe open up an upstream issue with Hugo to make it do the right thing, when postcss-cli isn't found and not rebuild the cache.

pelloq1 commented 3 years ago

I tried to install post-css but same result (with and without postcss="true" in config) :


Micro@LAPTOP-SPN2470S MINGW64 /c/Abacus-sync/sites/abacus (master)
$ npm install -g postcss-cli
C:\Users\Micro\AppData\Roaming\npm\postcss -> C:\Users\Micro\AppData\Roaming\npm\node_modules\postcss-cli\bin\postcss
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules\postcss-cli\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ postcss-cli@7.1.1
added 113 packages from 101 contributors in 14.96s

Micro@LAPTOP-SPN2470S MINGW64 /c/Abacus-sync/sites/abacus (master)
$ hugo
Building sites  WARN 2020/08/29 13:50:46 .File.Dir on zero object. Wrap it in if or with: {{ with .File }}{{ .Dir }}{{ end }}
Total in 458 ms
Error: Error building site: TOCSS: failed to transform "main.scss" (text/x-scss): resource "scss/styles/index.scss_02bf14281ac065540fcc7ecc15ca70a4" not found in file cache
stp-ip commented 3 years ago

Someone got it working with the current version and postcss-cli as well on windows: https://github.com/okkur/syna/issues/758#issuecomment-683072996 Hope that helps.

Happy for documentation contributions or comments that we can incorporate into documentation.

pelloq1 commented 3 years ago

Thanks you Michael,

It worked.

:-D

Micro@LAPTOP-SPN2470S MINGW64 /c/Abacus-sync/sites/abacus (master)
$ hugo
Building sites  WARN 2020/08/29 16:00:57 .File.Dir on zero object. Wrap it in if or with: {{ with .File }}{{ .Dir }}{{ end }}
You did not set any plugins, parser, or stringifier. Right now, PostCSS does nothing. Pick plugins for your case on https://www.postcss.parts/ and use them in postcss.config.js.

                   | FR | DE | EN
-------------------+----+----+-----
  Pages            | 49 | 41 | 36
  Paginator pages  |  0 |  0 |  0
  Non-page files   |  0 |  0 |  0
  Static files     | 23 | 23 | 23
  Processed images |  0 |  0 |  0
  Aliases          |  1 |  0 |  0
  Sitemaps         |  2 |  1 |  1
  Cleaned          |  0 |  0 |  0

Total in 1244 ms
stp-ip commented 3 years ago

Great to hear. Will leave this issue open until the underlying need for postcss-cli makes building the site a bit easier again.

0xffset commented 3 years ago

Hi, I had the same issue. To solved just I installed postcss with npm install postcss and npm install postcss-cli before to install npm install -g postcss-cli

stp-ip commented 3 years ago

This should be fixed with the ongoing release v0.17.4. Please reopen if it persists.