vite-ssg
vite-ssg copied to clipboard
I updated the version of vite SSG,compilation failed
I am using vitesee template to build my blog
Because I saw that vite see updated NPM. In package json。 So I also updated my code.
Then the node is deleted_ Modules and yen lock
Then after re yarn install
Finally, it can't be compiled
Error comes from newly installed package vue3-danmaku
https://github.com/hellodigua/vue-danmaku/blob/7e110197baf3fd9473175d28e6b26c24795c28ad/src/lib/Danmaku.vue#L150-L151
Try wrapping your component with client-only component:
<client-only>
<vue-danmaku :danmus="danmus"></vue-danmaku>
</client-only>
First of all, thank you for your reply
Did vite SSG update anything. I can use it before. It can't be used now.
Any code that depends on browser APIs like document
, window
should only be run on client side.
const isClient = typeof window !== 'undefined'
if(isClient) {
document.getElementById()
const app = cloudbase.init({})
}
If you have dependencies that has side effects import them dynamically or import in head.
if(isClient) {
const cloudbase = (await import('@cloudbase/js-sdk')).default;
await import('@cloudbase/js-sdk/auth')
const app = cloudbase.init({})
}
or
<!-- index.html -->
<head>
<script src="/cloudbase.full.js"></script>
</head>
Wow. You're awesome. My problem is almost solved
I think it should be the last question. This is an error. Did taiwind give it to me
Thanks and respect again
It's an issue with critters https://github.com/GoogleChromeLabs/critters/issues/86
This comment has workaround for it: https://github.com/GoogleChromeLabs/critters/issues/86#issuecomment-999679920
Thank you. I solved all the problems.
Because vite SSG has become great~
Welcome to have a look if you have time.
Finally, thank you very much
You're welcome, Your site looks cool 👌 Don't forget to close issue if your problem is solved 😉