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.

Trying to put together a Gatsby theme for mdx-deck, and running into some issues with loading web fonts.

A few of the fonts we use are available in Google Fonts, so I could go that way, but ideally I’d be able to use the typeface- packages (basically an encapsulation of web fonts including the necessary CSS/woff/etc. files) and then the path to the local webfont to get all the fonts we need (including Futura).

However, when I attempt to configure webpack with the css-loader and style-loader to load the CSS, the build breaks presumably because it’s statically rendered and window isn’t available.

$ mdx-deck build deck.js --webpack webpack.config.js [mdx-deck] building [mdx-deck] rendering static html webpack:///./node_modules/style-loader/lib/addStyles.js?:23 return window && document && document.all && !window.atob; ^

ReferenceError: window is not defined

Any insight here? This apparently must have worked at some point, because I see Kent C Dodds is using CSS and able to build content out–also note that checking out that project and running the build script exhibits the same issue!

For a reproduction, check out the example here

Thanks for the awesome work here, I love mdx-deck ❤️

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

5reactions
albinotonninacommented, Oct 21, 2018

Same, has to do with html static rendering (I’m not sure what that does actually)

--no-html during build solved my problem.

2reactions
with-heartcommented, Jan 27, 2019

In case anyone else runs into this issue, you can allow css require/import by installing style-loader and css-loader and then creating webpack.config.js:

module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [{loader: 'style-loader'}, {loader: 'css-loader'}],
      },
    ],
  },
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS Web Fonts - W3Schools
Web fonts allow Web designers to use fonts that are not installed on the user's computer. When you have found/bought the font you...
Read more >
How To Load and Use Custom Fonts with CSS | DigitalOcean
You can use the @font-face rule to load a custom font on a web page. The history of loading custom fonts has lead...
Read more >
The Easy Way to Add Fonts to Your Website (Including ...
How to add custom fonts to your website using @font-face · Step 1: Download the font · Step 2: Create a WebFont Kit...
Read more >
How to import Google Web Font in CSS file? - Stack Overflow
Go to selected font > Embed > @IMPORT > copy url and paste in your .css file above body tag. It's done. Share....
Read more >
How to use @font-face in CSS
The @font-face rule allows custom fonts to be loaded on a webpage. Once added to a stylesheet, the rule instructs the browser to...
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 Reddit Thread

No results found

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