vuejs / vue-style-loader

💅 vue style loader module for webpack
MIT License
226 stars 68 forks source link

vue-compoennt will happen when ssr is packaged in other projects. document is undefiend #44

Open mzkmzk opened 4 years ago

mzkmzk commented 4 years ago

Background:

I have a vue component library (my-component) and another nuxt project (my-project), my-project uses my_component through npm,

my-component is packaged in the form of webpack target=web and published to npm

Question:

my-project needs to be compatible with both ssr and spa (non-ssr)

nuxt mode: universal packaging

npm run build & npm run start will report an errordocument is undefined

Solve:

My idea is whether to add a judgment before this

if (!hasDocument) {
   return noop
 }

https://github.com/vuejs/vue-style-loader/blob/477c25e1a506c54e18cb443f7981aed6d4e80e65/lib/addStylesClient.js#L119-L120

pull request: #45