Skip to content

Commit

Permalink
Use per-request STATIC_URL for Vite assets (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
silviogutierrez authored Sep 9, 2024
1 parent 0da0380 commit 26ef326
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/reactivated/src/vite.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 26ef326

Please sign in to comment.