Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gatsby build failure: window not defined #103

Open
mrjoedang opened this issue Jun 9, 2019 · 2 comments
Open

Gatsby build failure: window not defined #103

mrjoedang opened this issue Jun 9, 2019 · 2 comments

Comments

@mrjoedang
Copy link

mrjoedang commented Jun 9, 2019

Running gatsby build gives the following error:

error Building static HTML failed
  15 |  * True if the custom elements polyfill is in use.
  16 |  */
> 17 | export const isCEPolyfill = window.customElements !== undefined &&
     |        ^
  18 |     window.customElements.polyfillWrapFlushCallback !==
  19 |         undefined;
  20 | /**


  WebpackError: ReferenceError: window is not defined

A temporary solution is to configure gatsby-node.js (as per https://www.gatsbyjs.org/docs/debugging-html-builds/#fixing-third-party-modules) as so:

exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
  if (stage === "build-html") {
    actions.setWebpackConfig({
      module: {
        rules: [
          {
            test: /wired/,
            use: loaders.null(),
          },
        ],
      },
    })
  }
}

Refer to gatsbyjs/gatsby#309 for a more permanent solution.

@pshihn
Copy link
Contributor

pshihn commented Aug 17, 2019

I have little experience with Gatsby/react in general. But I suspect this has something to do with the webpack tooling setup as you suggested.
WIll look more into this eventually

@pshihn
Copy link
Contributor

pshihn commented Jun 20, 2020

This is probably tied to SSR : #16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants