CloudCannon / bookshop

📚 A component development workflow for static websites.
MIT License
247 stars 21 forks source link

Describe Hugo minify configuration requirements #181

Closed markdumay closed 9 months ago

markdumay commented 9 months ago

When building my Hugo site with CloudCannon, I noticed npx @bookshop/generate could not find any pages that referenced a (custom) Bookshop component. My site did have a few test pages that referenced such a component. After some debugging, I noticed the following line was scanning the built HTML files for an HTML comment:

https://github.com/CloudCannon/bookshop/blob/6010d46d810d786d5c089980130759e4637546e6/javascript-modules/generate/lib/live-connector.js#L67

As it turns out, the --minify flag (which I had enabled in the CloudCannon build configuration / command line options) was purging all HTML comments from the output files. Adjusting the Hugo minify configuration fixed the issue and enabled the visual editing of the Bookshop component. I added the following configuration to hugo.toml:

[minify]
  [minify.tdewolff.html]
      keepComments = true

I prepared a small revision to the Hugo docs to help others who might encounter similar issues. To keep it concise, I linked to the Hugo docs only. Feel free to share your comments about this PR.

bglw commented 9 months ago

Hey @markdumay 👋

Thanks for the PR! Yes, this is something that should be better documented — I'll merge this and look to document it for the other relevant SSGs 🙂

Thanks again!