Skip to content

Prerender error and workarounds #178

@thangngoc89

Description

@thangngoc89

Preact-cli comes with prerender which render your / route using server-side rendering technique. So if you run npm start successfully but npm run build produces some errors, this mean that the prerender is failing because of some code requires DOM to work.

Workarounds:

  • Wrap your with this to make sure it won't execute when prerendering.
if (typeof window !== "undefined") {
  // Your code here
}
  • Turn off preredering by run npm run build -- --no-prerender

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions