You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code is heavily inspired by what has been done by Mermaid in their VitePress.
It works fine, but since most pages of my documentation contain a lot of graphs, I wanted to prebuild them. However, Mermaid is not compatible with SSR (mermaid-js/mermaid#3650).
Describe the solution you'd like
I would like to have access to the env mode in the Markdown-it context (in the env variable for example) so that I can conditionally add either the Mermaid component or a VPImage component with the path to the SVG I'd pre-generate in the buildEnd hook.
Describe alternatives you've considered
I tried to naively use mermaid-cli in Mermaid.vue instead of Mermaid when import.meta.env.SSR is truthy, but it fails as in SSR I apparently don't have access to Node.js modules.
I tried to use a v-if="import.meta.env.SSR" in the Mermaid component, but it gets sanitized with a work break between i and mport before being replaced by its value by Vite.
I considered spawning synchronously a node process that would generate the SVG upon parsing the markdown, but that would drastically slow down the build process.
Is your feature request related to a problem? Please describe.
My issue is related to pre-building the SVGs of Mermaid diagrams upon build using mermaid-cli.
In development mode, I use the normal version of Mermaid:
And I adapted the markdown-it instance to replace the mermaid code fences with that component:
The code is heavily inspired by what has been done by Mermaid in their VitePress.
It works fine, but since most pages of my documentation contain a lot of graphs, I wanted to prebuild them. However, Mermaid is not compatible with SSR (mermaid-js/mermaid#3650).
Describe the solution you'd like
I would like to have access to the env mode in the Markdown-it context (in the env variable for example) so that I can conditionally add either the Mermaid component or a VPImage component with the path to the SVG I'd pre-generate in the buildEnd hook.
Describe alternatives you've considered
I tried to naively use mermaid-cli in Mermaid.vue instead of Mermaid when import.meta.env.SSR is truthy, but it fails as in SSR I apparently don't have access to Node.js modules.
I tried to use a
v-if="import.meta.env.SSR"
in the Mermaid component, but it gets sanitized with a work break betweeni
andmport
before being replaced by its value by Vite.I considered spawning synchronously a node process that would generate the SVG upon parsing the markdown, but that would drastically slow down the build process.
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: