rodneyrehm / viewport-units-buggyfill

Making viewport units (vh|vw|vmin|vmax) work properly in Mobile Safari.
MIT License
1.59k stars 151 forks source link

Server side import #93

Closed Richacinas closed 6 years ago

Richacinas commented 6 years ago

Hello there,

I'm trying to use this library on a universal javascript application, and I get the error:

"window is not defined"

When Webpack is trying to compile es6 and bundle.

I'm guessing, there is no way to make this library work only client side??

Even just importing it, and not initializing, is throwing the error...

Richacinas commented 6 years ago

By now, I'm using the bundle and there is no problem anymore...

samlogan commented 6 years ago

Try this:

const viewportUnitsBuggyfill = typeof window !== 'undefined' ? require('viewport-units-buggyfill') : null;