Skip to content

Commit fb9caad

Browse files
committed
fix: use proper prod asset paths
1 parent aa10349 commit fb9caad

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/server/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ app.get("/parameters/:shareId?/:example?", async (c, next) => {
6060
<body>
6161
<div id="root"></div>
6262
<script type="module">{`window.CODE = ${JSON.stringify(exampleCode)}`}</script>
63-
<script type="module" src={getAssetPath("/src/client/index.tsx")}></script>
63+
<script type="module" src={getAssetPath("/src/client/index.tsx", "client.js")}></script>
6464
</body>
6565
</html>,
6666
),

src/server/utils.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import type { FC } from "react";
22

3-
export const getAssetPath = (assetPath: string): string => {
3+
export const getAssetPath = (
4+
assetPath: string,
5+
prodFileName?: string,
6+
): string => {
47
if (import.meta.env.PROD) {
58
const pathParts = assetPath.split("/");
6-
return pathParts[pathParts.length - 1];
9+
return `/assets/${prodFileName ?? pathParts[pathParts.length - 1]}`;
710
} else {
811
return assetPath;
912
}

0 commit comments

Comments
 (0)