Skip to content
Merged
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
9 changes: 8 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,12 @@ function inlineAsset(html: string, fileName: string, item: Rolldown.OutputChunk
if (!scriptTag.test(html)) {
return null;
}
// With codeSplitting off, Vite never fills the `__VITE_PRELOAD__` deps placeholder
// it puts in each dynamic `import()` wrapper, so the first lazy import throws a
// ReferenceError (ColliderLab, MolScope). One chunk has nothing to preload, and the
// helper skips preloading when its deps argument is undefined.
// Escape `</script>` so an inlined occurrence cannot close the tag early.
const code = item.code.replace(/<\/script>/g, "<\\/script>");
const code = item.code.replaceAll("__VITE_PRELOAD__", "void 0").replace(/<\/script>/g, "<\\/script>");
return html.replace(scriptTag, () => `<script type="module">${code}</script>`);
}

Expand Down Expand Up @@ -408,6 +412,9 @@ export default defineConfig(({ mode }) => {
},
workbox: {
maximumFileSizeToCacheInBytes: WORKBOX_MAX_FILE_BYTES,
// Lets <Pages URL>/<Repo>-single.html (the build:single file Baton's deploy.yml adds
// after this build) reach returning visitors instead of the fallback index.html.
navigateFallbackDenylist: [/-single\.html$/],
globPatterns: [
`**/*.{${["js", "css", "html", "svg", "png", "woff2", ...simConfig.precacheExtensions].join(",")}}`,
],
Expand Down
Loading