scania / corporate-ui

This repo will be archived in Q3 2021, please visit https://github.com/scania-digital-design-system
https://digitaldesign.scania.com/
25 stars 15 forks source link

Bug - GatsbyJS production build fails with SDDS #607

Open magnusarinell opened 3 years ago

magnusarinell commented 3 years ago

Describe the bug
I'm using GatsbyJS to build a site with SDDS. Doing a production build of the site with gatsby build fails because during the Gatsby production build the window object is undefined, and there are dependencies in SDDS which does not take this into account. What's needed in SDDS is some checks that typeof(window) !== 'undefined'.

As a consequence of this I need to add code which excludes SDDS during my production build step, but it gives some drawback since the SSR pages do not include stylings from SDDS, and I need to make sure I render my UI only after everything has mounted.

To Reproduce

  1. Clone a GatsbyJS starter
  2. Add SDDS dependencies and include the setup in gatsby-browser.js and gatsby-ssr.js.
  3. Start the development server. Site renders nicely on http://localhost:8000
  4. Run gatsby build. Error.

Expected behavior
A successful gatsby build for a GatsbyJS site using SDDS.

Version of Corporate-ui
4.1.2

Framework and version

Application link