diff --git a/apps/web/src/index.ts b/apps/web/src/index.ts index b2c23257..e4fd4b03 100644 --- a/apps/web/src/index.ts +++ b/apps/web/src/index.ts @@ -89,7 +89,17 @@ async function run() { const mainHtmlHeaders = bundle.files.find((f) => f.path === bundle.index)?.headers || { 'content-type': 'text/html;charset=utf-8', } - const serveMainHtml = () => new Response(mainHtmlFile, { headers: mainHtmlHeaders }) + let mainHtmlText = '' + const serveMainHtml = async () => { + if (!mainHtmlText) { + const raw = await mainHtmlFile.text() + mainHtmlText = raw + .replaceAll('href="./', 'href="/') + .replaceAll('src="./', 'src="/') + .replaceAll('content="./', 'content="/') + } + return new Response(mainHtmlText, { headers: mainHtmlHeaders }) + } routes['/'] = serveMainHtml routes['/*'] = serveMainHtml diff --git a/build.ts b/build.ts index f5aac79b..b9a7e346 100644 --- a/build.ts +++ b/build.ts @@ -19,7 +19,8 @@ await Bun.build({ root: '.', target: 'bun', outdir: outdir, - minify: false, + minify: true, + splitting: true, naming: '[name].[ext]', plugins: [ temporalWorkflow({ @@ -44,5 +45,4 @@ await Bun.build({ define: { 'process.env.NODE_ENV': JSON.stringify('production'), }, - publicPath: '/', }) diff --git a/scripts/build-npm.ts b/scripts/build-npm.ts index adb021d4..99da29f8 100644 --- a/scripts/build-npm.ts +++ b/scripts/build-npm.ts @@ -237,13 +237,13 @@ async function buildMainPackage({ target: 'bun', outdir: binOutDir, minify: true, + splitting: true, naming: `${appName}-app.[ext]`, plugins, external, define: { 'process.env.NODE_ENV': JSON.stringify('production'), }, - publicPath: '/', }) if (!buildResult.success) {