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