Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
import { defineConfig } from "astro/config";

// Prevent duplicate customElements.define() errors in dev mode.
// The myst-awesome library imports Web Awesome components from many
// separate <script> entry points, which Astro/Vite can execute more
// than once. This patches define() to silently skip duplicates.
function safeCustomElements() {
return {
name: "safe-custom-elements",
hooks: {
"astro:config:setup"({ injectScript }) {
injectScript(
"head-inline",
`{
const orig = customElements.define.bind(customElements);
customElements.define = function (name, ctor, opts) {
if (!customElements.get(name)) orig(name, ctor, opts);
};
}`
);
},
},
};
}

export default defineConfig({
// Use the myst-awesome theme configuration
integrations: [],
integrations: [safeCustomElements()],

server: {
port: 4321, // Use port 4321 for the main project
Expand Down
Loading