From 26ef326e0b3e724bb231de327a659f5468c6e93a Mon Sep 17 00:00:00 2001 From: Silvio Date: Mon, 9 Sep 2024 15:32:54 -0400 Subject: [PATCH] Use per-request STATIC_URL for Vite assets (#379) --- packages/reactivated/src/vite.mts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/reactivated/src/vite.mts b/packages/reactivated/src/vite.mts index c9d08c00..ff8ffb95 100644 --- a/packages/reactivated/src/vite.mts +++ b/packages/reactivated/src/vite.mts @@ -87,7 +87,14 @@ app.use("/_reactivated/", async (req, res) => { }; const url = context.request.path; - const viteHead = await vite.transformIndexHtml(url, ""); + // For E2E tests, we may want to run them pointing to a running vite + // instance for a quick feedback loop. Intead of the traditional python + // manage.py build step necessary. So we ensure vite head always + // points to the per-request STATIC_URL. + const viteHead = (await vite.transformIndexHtml(url, "")).replace( + base, + `${context.STATIC_URL}dist/`, + ); const rendered = await render(req, viteHead, "development", "index"); res.status(200).set({"Content-Type": "text/html"}).end(rendered);