I updated the version of vite SSG,compilation failed
admin8756 opened this issue · comments
Error comes from newly installed package vue3-danmaku
Try wrapping your component with client-only component:
<client-only>
<vue-danmaku :danmus="danmus"></vue-danmaku>
</client-only>
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>
It's an issue with critters GoogleChromeLabs/critters#86
This comment has workaround for it: GoogleChromeLabs/critters#86 (comment)
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 😉