I'm getting the following error inside my Gatsby with Sanity app on running npm run build
:
WebpackError: ReferenceError: window is not defined (from plugin: gatsby-plugi
n-styled-components)
Seems to be that the external package gatsby-plugin-styled-components
is using window
somewhere.I've tried replacing by a dummy module as described here https://www.gatsbyjs.com/docs/debugging-html-builds/#fixing-third-party-modules except my styled-components does not work then so it is not a solution.
Perhaps I'm using styled component techniques where are not supported? I've looked at different gatsby/styled components example repo's and cannot find the difference.
You can find the repo here: https://github.com/sanderdebr/sanity-gatsby-portfolio