Hello everyone. I have started to use vite ssr and ssg in my project now and decided to integrate porsive/wysimark into the project. But it does not seem to work around the concept of ssg and ssr. It keeps saying document is not defined during the build and won't compile at all.
I have tried
Wrapping the <Wysimark /> component with <ClientOnly />
Add the module into ssr.noExternal in vite.config.ts
Register the Wysimark component globally after isClient is true.
This is the repository for some minimal reproduction code.
This is the error that happened when building the page
[vite-ssg] An internal error occurred.
[vite-ssg] Please report an issue, if none already exists: https://github.com/antfu/vite-ssg/issues
file:///D:/coding-projects/rfcx/vue-wysimark-vite-ssg/.vite-ssg-temp/fyqzbzosyf/main.mjs:86843
var ad = document.createElement("i");
^
ReferenceError: document is not defined
at file:///D:/coding-projects/rfcx/vue-wysimark-vite-ssg/.vite-ssg-temp/fyqzbzosyf/main.mjs:86843:10
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
This is a bug/design choice that the package you are using is not compatible with running on Node (SSG/SSR). Please report to that package, or make your usage as client only.
Describe the bug
Hello everyone. I have started to use vite ssr and ssg in my project now and decided to integrate porsive/wysimark into the project. But it does not seem to work around the concept of ssg and ssr. It keeps saying
document is not defined
during the build and won't compile at all.I have tried
<Wysimark />
component with<ClientOnly />
ssr.noExternal
invite.config.ts
Wysimark
component globally afterisClient
is true.This is the repository for some minimal reproduction code.
This is the error that happened when building the page
My
vite.config.ts
that caused this errorThis is how I used the module inside the page.
Thank you for this awesome module and please reply in the page if you want further clarification.
Reproduction
https://github.com/grindarius/vue-with-wysimark-and-vite-ssg
System Info
Used Package Manager
pnpm
Validations