Skip to content

Commit

Permalink
[#63734] Force the main js file name and reapply mermaid graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
Trzcin authored and mgielda committed Aug 8, 2024
1 parent 7fae357 commit 23413c0
Show file tree
Hide file tree
Showing 4 changed files with 464 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"test": "PW_TEST_HTML_REPORT_OPEN=never playwright test -c tests/playwright.config.js --reporter html"
},
"dependencies": {
"@agoose77/markdown-it-mermaid": "^1.1.0",
"@codemirror/commands": "^6.2.4",
"@codemirror/lang-markdown": "^6.2.3",
"@codemirror/merge": "@6.0.0",
Expand Down
8 changes: 7 additions & 1 deletion src/hooks/useText.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import markdownIt from "markdown-it";
import { markdownReplacer, useCustomRoles } from "./markdownReplacer";
import { useCallback, useEffect, useMemo, useReducer, useState } from "preact/hooks";
import IMurMurHash from "imurmurhash";
import markdownItMermaid from "@agoose77/markdown-it-mermaid";

const countOccurences = (str, pattern) => (str?.match(pattern) || []).length;

Expand Down Expand Up @@ -62,7 +63,12 @@ export const useText = ({ initialText, transforms, customRoles, preview }) => {
}, []);

const markdown = useMemo(
() => markdownIt({ breaks: true, linkify: true }).use(markdownitDocutils).use(markdownReplacer(transforms)).use(useCustomRoles(customRoles)),
() =>
markdownIt({ breaks: true, linkify: true })
.use(markdownitDocutils)
.use(markdownReplacer(transforms))
.use(useCustomRoles(customRoles))
.use(markdownItMermaid),
[],
);

Expand Down
14 changes: 14 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ export default defineConfig({
rollupOptions: {
output: {
assetFileNames: 'MystEditor.css',
chunkFileNames: (chunk) => {
if (chunk.name === "MystEditor") {
// This will be the main MystEditor library file
return "MystEditor.js";
}
return "[name]-[hash].js";
},
entryFileNames: (chunk) => {
if (chunk.name === "MystEditor") {
// This will apply to files generated for the index.html MyST demo
return "MystEditorDemo.js";
}
return "[name].js";
}
}
}
},
Expand Down
Loading

0 comments on commit 23413c0

Please sign in to comment.