Skip to content

Commit

Permalink
Merge pull request #65 from bonyuta0204/fix/production-build-vite5
Browse files Browse the repository at this point in the history
fix: production build in vite5
  • Loading branch information
emersonbottero committed Nov 27, 2023
2 parents 4fe352b + f21365c commit bf6f6c9
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/mermaid-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface MermaidPluginOptions extends MermaidConfig {

// Additional configuration for plugin itself. Separate model, not to risk name conflicts with future MermaidConfig options
export interface MermaidPluginConfig {
class?: string;
class?: string;
}

const DEFAULT_OPTIONS: MermaidConfig = {
Expand Down Expand Up @@ -42,10 +42,21 @@ export function MermaidPlugin(
src =
"\nimport Mermaid from 'vitepress-plugin-mermaid/Mermaid.vue';\n" +
src;
src = src.replace(
"// install global components",
"// install global components\n\t\tapp.component('Mermaid', Mermaid);\n"

const lines = src.split("\n");

const targetLineIndex = lines.findIndex((line) =>
line.includes("app.component")
);

lines.splice(
targetLineIndex,
0,
' app.component("Mermaid", Mermaid);'
);

src = lines.join("\n");

return {
code: src,
map: null, // provide source map if available
Expand Down

0 comments on commit bf6f6c9

Please sign in to comment.