diff --git a/site/package.json b/site/package.json index 8dc43f6ee0..110d1cff06 100644 --- a/site/package.json +++ b/site/package.json @@ -9,7 +9,6 @@ "directory": "site" }, "private": true, - "main": "./source/entry-empty.js", "engines": { "node": ">=12.16.1" }, diff --git a/site/prerender.cjs b/site/prerender.cjs index ad39be3615..9a752e41f8 100644 --- a/site/prerender.cjs +++ b/site/prerender.cjs @@ -3,6 +3,7 @@ // CommonJS when I wrote it. // cf. https://github.com/vitejs/vite/blob/133fcea5223263b0ae08ac9a0422b55183ebd266/packages/vite/src/node/build.ts#L495 // cf. https://github.com/vitejs/vite/pull/2157 +// cf. https://github.com/vitejs/vite/pull/6812 // TODO: We could use something like https://github.com/Aslemammad/tinypool to // prerender all pages in parallel (used by vitest). Or move to SSR with a diff --git a/site/source/entry-empty.js b/site/source/entry-empty.js deleted file mode 100644 index 5409001a3c..0000000000 --- a/site/source/entry-empty.js +++ /dev/null @@ -1,3 +0,0 @@ -// TODO: for some reason (ViteJS bug or missconfiguration on our side?) we need -// to define a entry file in the "main" field of package.json. We should remove -// this empty file when this problem is fixed. diff --git a/site/vite.config.ts b/site/vite.config.ts index b3c2d14f57..98fa5c1d80 100644 --- a/site/vite.config.ts +++ b/site/vite.config.ts @@ -157,20 +157,19 @@ function multipleSPA(options: MultipleSPAOptions): Plugin { // eslint-disable-next-line @typescript-eslint/no-misused-promises vite.middlewares.use(async (req, res, next) => { const url = req.originalUrl + const firstLevelDir = url?.slice(1).split('/')[0] + if (url === '/') { res.writeHead(302, { Location: '/' + options.defaultSite }) res.end() } else if ( - url && - Object.keys(options.sites).some((name) => - url.slice(1).startsWith(name) - ) + firstLevelDir && + Object.keys(options.sites).some((name) => firstLevelDir === name) ) { - const siteName = url.slice(1).split('/')[0] + const siteName = firstLevelDir const content = await vite.transformIndexHtml( - '/', - await fillTemplate(siteName), - url + url, + await fillTemplate(siteName) ) res.end(content) } else {