From 40aa71b2b47df891665dd3f79066233c07db7e5d Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 19 May 2025 20:04:51 +0300 Subject: [PATCH] fix(vite): serving of source assets --- apps/client/vite.config.ts | 6 +++--- apps/server/src/routes/assets.ts | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/apps/client/vite.config.ts b/apps/client/vite.config.ts index d5c17cc15..16402592a 100644 --- a/apps/client/vite.config.ts +++ b/apps/client/vite.config.ts @@ -55,9 +55,9 @@ export default defineConfig(() => ({ runtime: join(__dirname, "src", "runtime.ts") }, output: { - entryFileNames: "[name].js", - chunkFileNames: "[name].js", - assetFileNames: "[name,].js" + entryFileNames: "src/[name].js", + chunkFileNames: "src/[name].js", + assetFileNames: "src/[name,].js" }, onwarn(warning, rollupWarn) { if (warning.code === "MODULE_LEVEL_DIRECTIVE") { diff --git a/apps/server/src/routes/assets.ts b/apps/server/src/routes/assets.ts index 0007b4577..74f2e00eb 100644 --- a/apps/server/src/routes/assets.ts +++ b/apps/server/src/routes/assets.ts @@ -25,13 +25,11 @@ async function register(app: express.Application) { if (!publicUrl) { throw new Error("Missing TRILIUM_PUBLIC_SERVER"); } - app.use(`/@fs`, proxy(publicUrl, { - proxyReqPathResolver: (req) => `/@fs` + req.url + app.use(assetPath + `/@fs`, proxy(publicUrl, { + proxyReqPathResolver: (req) => assetPath + `/@fs` + req.url })) } else { - const clientStaticCache = persistentCacheStatic(path.join(resourceDir, "public")); - app.use(`/${assetPath}/app`, clientStaticCache); - app.use(`/${assetPath}/app-dist`, clientStaticCache); + app.use(`/${assetPath}/src`, persistentCacheStatic(path.join(resourceDir, "public", "src"))); app.use(`/${assetPath}/stylesheets`, persistentCacheStatic(path.join(resourceDir, "public", "stylesheets"))); app.use(`/${assetPath}/libraries`, persistentCacheStatic(path.join(resourceDir, "public", "libraries"))); app.use(`/${assetPath}/fonts`, persistentCacheStatic(path.join(resourceDir, "public", "fonts")));