Skip to content

Commit

Permalink
fix: windows entry paths
Browse files Browse the repository at this point in the history
  • Loading branch information
rossrobino committed Sep 18, 2024
1 parent a151c28 commit 74f1827
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/nice-frogs-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"domco": patch
---

fix: windows entry point paths
10 changes: 6 additions & 4 deletions packages/domco/src/plugin/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const configPlugin = async (
chunkFileNames: `${isSsrBuild ? "" : dirNames.out.client.immutable + "/"}chunks/[name]/[hash].js`,
},
},
// rel=modulepreload is supported in all major browsers as of 2023
// `rel=modulepreload` is supported in all major browsers as of 2023
// https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/modulepreload#browser_compatibility
modulePreload: false,
},
Expand Down Expand Up @@ -107,7 +107,7 @@ const clientEntry = async () => {
}),
]);

// rename keys
// rename "/" keys to main
if (pages["/"]) {
pages.main = pages["/"];
delete pages["/"];
Expand All @@ -117,14 +117,16 @@ const clientEntry = async () => {
delete scripts["/"];
}

// pages and scripts have to start with "src/" instead of just "/client"
// for builds to work on Windows
for (const [key, value] of Object.entries(pages)) {
pages[key] = value.slice(dirNames.src.base.length + 1); // remove "/src"
pages[key] = value.slice(1); // remove "/"
}

const scriptsEntry: Record<string, string> = {};

for (const [key, value] of Object.entries(scripts)) {
scriptsEntry[`/_script${key}`] = value.slice(dirNames.src.base.length + 1); // remove "/src"
scriptsEntry[`/_script${key}`] = value.slice(1); // remove "/"
}

return Object.assign(pages, scriptsEntry);
Expand Down

0 comments on commit 74f1827

Please sign in to comment.