Vite fixes (#8537)

This commit is contained in:
Elian Doran
2026-01-29 09:26:57 +02:00
committed by GitHub
4 changed files with 6 additions and 6 deletions

View File

@@ -19,7 +19,7 @@
<!-- This works even when the user directly changes --root-background in CSS -->
<div id="background-color-tracker" style="position: absolute; visibility: hidden; color: var(--root-background); transition: color 1ms;"></div>
<script src="./index.ts" type="module"></script>
<script src="./src/index.ts" type="module"></script>
<!-- Required for correct loading of scripts in Electron -->
<script>

View File

@@ -30,7 +30,7 @@ async function initJQuery() {
}
async function setupGlob() {
const response = await fetch(`/bootstrap${window.location.search}`);
const response = await fetch(`./bootstrap${window.location.search}`);
const json = await response.json();
window.global = globalThis; /* fixes https://github.com/webpack/webpack/issues/10035 */

View File

@@ -85,7 +85,7 @@ export default defineConfig(() => ({
sourcemap: false,
rollupOptions: {
input: {
index: join(__dirname, "src", "index.html"),
index: join(__dirname, "index.html"),
login: join(__dirname, "src", "login.ts"),
setup: join(__dirname, "src", "setup.ts"),
set_password: join(__dirname, "src", "set_password.ts"),

View File

@@ -47,10 +47,10 @@ async function register(app: express.Application) {
vite.middlewares(req, res, next);
});
app.get(`/`, [ rootLimiter, auth.checkAuth, csrfMiddleware ], (req, res, next) => {
req.url = `/${assetUrlFragment}/src/index.html`;
req.url = `/${assetUrlFragment}/index.html`;
vite.middlewares(req, res, next);
});
app.get(`/index.ts`, [ rootLimiter ], (req, res, next) => {
app.get(`/src/index.ts`, [ rootLimiter ], (req, res, next) => {
req.url = `/${assetUrlFragment}/src/index.ts`;
vite.middlewares(req, res, next);
});
@@ -66,7 +66,7 @@ async function register(app: express.Application) {
// broken when closing the browser and coming back in to the page.
// The page is restored from cache, but the API call fail.
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
res.sendFile(path.join(publicDir, "src", "index.html"));
res.sendFile(path.join(publicDir, "index.html"));
});
app.use("/assets", persistentCacheStatic(path.join(publicDir, "assets")));
app.use(`/src`, persistentCacheStatic(path.join(publicDir, "src")));