Closed Dave3of5 closed 2 years ago
This is correct behavior. If you'll take a look at the full error (it looks like you cut off the first few lines), you'll see:
ReferenceError: document is not defined
Hash routers depend on the DOM, which is unavailable when prerendering as this happens in Node.
You can opt out of prerendering in preact-cli
with the --no-prerender
flag, see: preact-cli#pre-rendering
Excellent thanks for that answer @rschristian. Maybe just needs the README updated then to include this.
Hash routing as explained on the readme.md breaks the build:
Create a new default app:
npx preact-cli create default my-project
Add history package:
npm install --save history
Add following to app.js:
Run build:
npm run build
Build crashes.