question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error during production build when using Preact plugin

See original GitHub issue

When I add the Preact plugin development works fine, but when I run gatsby build I get this:

error Building static HTML for pages failed

See our docs page on debugging HTML builds for help https://goo.gl/yL9lND

  60 |     }
  61 |
> 62 |     if (location.pathname === rootPath) {
     |                  ^
  63 |       header = (
  64 |         <h1>
  65 |           <Linker to={'/'}>Gatsby Starter Blog</Linker>


  WebpackError: Cannot read property 'pathname' of undefined

  - index.js:62 Template.render
    src/layouts/index.js:62:18

  - preact-compat.js:496 callMethod
    ~/preact-compat/dist/preact-compat.js:496:1

  - preact-compat.js:507 Template.render
    ~/preact-compat/dist/preact-compat.js:507:1

  - index.js:155 renderToString
    ~/preact-render-to-string/dist/index.js:155:1

  - index.js:162 renderToString
    ~/preact-render-to-string/dist/index.js:162:1

  - index.js:162 renderToString
    ~/preact-render-to-string/dist/index.js:162:1

  - index.js:162 renderToString
    ~/preact-render-to-string/dist/index.js:162:1

  - index.js:162 renderToString
    ~/preact-render-to-string/dist/index.js:162:1

  - index.js:162 renderToString
    ~/preact-render-to-string/dist/index.js:162:1

  - gatsby-ssr.js:25 Object.exports.replaceRenderer
    ~/gatsby-plugin-styletron/gatsby-ssr.js:25:1

When I remove the plugin the production build is successful.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
kakadiadarpancommented, Oct 9, 2018

@codejet Preact support for Gatsby 2 is broken currently.

Since you have upgraded to Gatsby v2, we’ll be closing this in favor of #8545

0reactions
codejetcommented, Oct 7, 2018

After upgrading to Gatsby 2 there is a different issue which is described here https://github.com/gatsbyjs/gatsby/issues/8545

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging Preact Apps
How to debug Preact applications when something goes wrong.
Read more >
Error Boundaries
Error boundaries catch errors during rendering, in lifecycle methods, and in ... If you don't use Create React App, you can add this...
Read more >
preact build does not work when Webpack 5 is installed
In that project, trying to run preact build <args> from an npm build script failed. Following that, I created a minimal Preact application...
Read more >
Gatsby Changelog | 5.3.0
When you saw the error "Building static HTML failed for path . ... For example, in gatsby-plugin-image you were able to use it...
Read more >
Error handling for production application in Preact
Preact is a great alternative to React. It is made for creating modern Web Application and weights a... Tagged with preact, tutorial, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found