Using Preact with Docusaurus #4832
-
Hey hey! I'm having some trouble, so I was wondering if anyone more involved in the project may have some insight. I maintain SVGO.dev, a small website generated with Docusaurus (an SSG), and I'd like to migrate it from React to Preact. Unfortunately, by adopting Preact, I seem to have broken SSR. After following the Switching to Preact guide, the production build works and produces the JAMstack friendly output, but it outputs a CSR application which doesn't work at all without JavaScript enabled. (Normally, building a Docusaurus site builds the website with SSR, and outputs the built HTML with a lighter JS bundle to hydrate interactivity. The bulk of the website works even if JavaScript is disabled.) I have read Server-Side Rendering in your documentation, and can see you have a dedicated package for it, but not any kind of alias. Does this mean Docusaurus would either have to have explicit support for Preact SSR, or that I'd need to write a Yarn patch? Or is there a way to already retrofit this behavior that I'm just missing? I was confused here because there are no errors/warnings at all. If anyone could provide guidance or a good starting point at what to look for based on the symptoms described, that'd be appreciated! My branch so far for svg/svgo.dev with the migration to Preact: Thanks, and no pressure if there's limited support available. I understand you can't know about every framework out there. 👍 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
Will take a look shortly, but Line 1 in 2d6811d Line 80 in 2d6811d |
Beta Was this translation helpful? Give feedback.
Alrightly, after a bunch of blind fiddling I seem to have gotten it working. I avoid dealing with Yarn, so can't really submit a patch as it wouldn't address the lockfile, but once you've gotten
react
fully out ofnode_modules
, you should just need to comment out line183
ofnode_modules/react-loadable/lib/index.js
-- no idea why that fails, or why that module is even needed today, but builds do seem to work once that's corrected.