Skip to content

Commit bf6f6c9

Browse files
Merge pull request #65 from bonyuta0204/fix/production-build-vite5
fix: production build in vite5
2 parents 4fe352b + f21365c commit bf6f6c9

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/mermaid-plugin.ts

+15-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface MermaidPluginOptions extends MermaidConfig {
1111

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

1717
const DEFAULT_OPTIONS: MermaidConfig = {
@@ -42,10 +42,21 @@ export function MermaidPlugin(
4242
src =
4343
"\nimport Mermaid from 'vitepress-plugin-mermaid/Mermaid.vue';\n" +
4444
src;
45-
src = src.replace(
46-
"// install global components",
47-
"// install global components\n\t\tapp.component('Mermaid', Mermaid);\n"
45+
46+
const lines = src.split("\n");
47+
48+
const targetLineIndex = lines.findIndex((line) =>
49+
line.includes("app.component")
50+
);
51+
52+
lines.splice(
53+
targetLineIndex,
54+
0,
55+
' app.component("Mermaid", Mermaid);'
4856
);
57+
58+
src = lines.join("\n");
59+
4960
return {
5061
code: src,
5162
map: null, // provide source map if available

0 commit comments

Comments
 (0)