vuejs / vue-style-loader

💅 vue style loader module for webpack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

mzkmzk opened this issue · comments

commented

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 error document is undefined

Solve:

My idea is whether to add a judgment before this

if (!hasDocument) {
   return noop
 }

var update, remove
var styleElement = document.querySelector('style[' + ssrIdKey + '~="' + obj.id + '"]')

pull request: #45