arielsalminen / vue-design-system

An open source tool for building UI Design Systems with Vue.js
https://vueds.com
MIT License
2.17k stars 225 forks source link

window is not defined when using VDS in Nuxt #140

Open michaelpumo opened 5 years ago

michaelpumo commented 5 years ago

It doesn't matter if I build my design system as umd or commonjs2, when using the design system in a Nuxt project I get the window is not defined error.

Of course, some components in my design system use window (they have to) but my question is that when building the system, how are we able to tell Nuxt not to choke on these references? Every component is lumped together in one single JS and CSS file.

I have followed the steps outlined here multiple times, being very careful to follow every step: https://github.com/viljamis/nuxt-design-system

The result is always the same.

The only way I can get around these errors is to specify ssr: false in my Nuxt config for the plugin that imports the design system, but that defeats the point of using Nuxt at all. I need a level of SSR.

Any ideas? I can't possibly be the only one hitting this issue?

arielsalminen commented 5 years ago

@michaelpumo I imagine currently you’d have to check for window existence in the component itself to go around this issue?